fix: restore exact focus after pane creation - #346
Conversation
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_547c9e94-0ca1-48a8-84b6-0277a5284452) |
|
Warning Review limit reached
Next review available in: 47 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (10)
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 |
| // parameter is not part of cmuxlayer's verified socket contract. Route an | ||
| // explicit preference through the pinned CLI instead of risking a silently | ||
| // ignored socket field. | ||
| if (opts?.focus !== undefined) { |
There was a problem hiding this comment.
🟠 High src/cmux-socket-client.ts:416
newSplit in CmuxSocketClient throws unsupported_focus_option when focus: true is passed on a socket-only instance without a CLI fallback, even though true is the socket's default behavior. Only focus: false needs to be routed through the CLI. The current guard at line 416 checks opts?.focus !== undefined, which catches true and causes a regression for callers that pass focus: true explicitly.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @src/cmux-socket-client.ts around line 416:
`newSplit` in `CmuxSocketClient` throws `unsupported_focus_option` when `focus: true` is passed on a socket-only instance without a CLI fallback, even though `true` is the socket's default behavior. Only `focus: false` needs to be routed through the CLI. The current guard at line 416 checks `opts?.focus !== undefined`, which catches `true` and causes a regression for callers that pass `focus: true` explicitly.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f98f50ec0a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (focused?.workspace_ref) { | ||
| return { | ||
| workspace: focused.workspace_ref, | ||
| ...(focused.surface_ref ? { surface: focused.surface_ref } : {}), |
There was a problem hiding this comment.
Preserve stable UUIDs in focus leases
When cmux restarts or recycles refs during a readiness wait, this stores only the process-local surface:N ref and later both compares it and passes it as surface_id to surface.focus. The type contract in src/types.ts explicitly distinguishes this mutable ref from the stable surface UUID, so a recycled ref can make the lease appear unchanged and restore focus to the wrong pane. Resolve and retain the stable UUID in each focus target before waiting.
AGENTS.md reference: AGENTS.md:L38-L39
Useful? React with 👍 / 👎.
| if (!args.pane && !args.surface) { | ||
| priorFocus = await focusTargetBeforeSplit(targetWorkspace); | ||
| focusRestoreLease = await focusTargetBeforeSplit( | ||
| targetWorkspace, | ||
| args.focus !== true, | ||
| ); |
There was a problem hiding this comment.
Capture leases for explicitly anchored splits
When new_split is called with pane or surface and focus is omitted or false, this condition skips focus capture entirely. The commit also stops forwarding focus to client.newSplit, so cmux can focus the newly created surface while capturePostCreationFocus(null) and the eventual restore are no-ops, contradicting the tool's promise to restore the exact origin unless focus:true is requested. Capture the origin lease for anchored creations as well.
Useful? React with 👍 / 👎.
Summary
Verification
Review dispositions
send/send-key(their CLI path has no focus argument or focus call), but the cmux app could still focus as an undocumented input side effect. This is narrowed, not closed, pending installed live verification.CmuxClient.newSurfacedoes not forward its currently-unusedfocusoption.PR #343 and its worktree are intentionally untouched. Release, fleet reconnect, and Etan-observed live verification are owned by the lead; this PR is merged, not declared live-done.