Repository navigation
fix: Slow Unity responses now bring the Editor forward - #1353
Conversation
Focus recovery previously only ran after undispatched connection failures, so accepted-but-stalled Unity requests never triggered the Windows focus warmup path. - Add typed main-thread stall reporting from IPC heartbeats. - Focus once for pre-accept timeouts, heartbeat stalls, heartbeat silence, and abnormal final response timeouts while skipping server_busy and intentional compile polling timeouts. - Restore Windows foreground focus with AttachThreadInput after recoverable focus attempts, preserve maximized windows, and leave Unity visible after terminal timeout failures.
|
Warning Review limit reached
More reviews will be available in 12 minutes and 10 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughIntroduces a ChangesConnection Retry Focus Controller, IPC Stall Handler, and Windows Restore
Sequence Diagram(s)sequenceDiagram
participant RetryLoop as sendWithTransientConnectionRetry
participant Controller as connectionRetryFocusController
participant IPCClient as unityipc.Client
participant FocusScript as focusUnityProcess
RetryLoop->>Controller: newConnectionRetryFocusController(...)
RetryLoop->>IPCClient: WithMainThreadStallHandler(controller.onMainThreadStall)
IPCClient-->>Controller: onMainThreadStall(stallSeconds) [on threshold]
Controller->>FocusScript: tryFocus(main_thread_stall, ...)
RetryLoop->>RetryLoop: error occurs → connectionRetryFocusReasonForError
RetryLoop->>Controller: tryFocus(reason, ...) + keepUnityFocusedAfterReturn
RetryLoop->>Controller: doRestoreFocus [deferred on return]
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
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 `@cli/internal/cli/connection_retry.go`:
- Around line 107-109: The issue is that in the tryFocus function at lines
107-109, setting controller.attempted = true when process discovery fails or
returns nil permanently marks the focus attempt as complete, preventing the
terminal-timeout path at lines 232-235 from retrying focus recovery on the same
reused controller. When process discovery fails transiently, this overly
aggressive flag prevents the final recovery attempt from succeeding. Fix this by
not setting controller.attempted = true in the error case where runningProcess
discovery fails or returns nil, allowing the later terminal-timeout path to
still attempt focus recovery if needed.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: bd1cd2af-f595-4c8b-8f9c-b673b3a2b3d3
📒 Files selected for processing (6)
cli/internal/cli/connection_retry.gocli/internal/cli/connection_retry_test.gocli/internal/cli/focus.gocli/internal/cli/focus_test.gocli/internal/unityipc/client.gocli/internal/unityipc/client_heartbeat_test.go
There was a problem hiding this comment.
2 issues found across 6 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
A transient Unity process lookup failure should not consume the one focus attempt for a command. Leave the controller retryable until a real process focus attempt runs, and cover the later terminal-timeout recovery path with a focused test.
Summary
User Impact
Changes
Verification