fix: fall back window screenshots to Device Simulator#1767
Conversation
When Device Simulator replaces the Game tab, the default --window-name Game finds nothing. Retry with Simulator so unspecified window capture still returns a chrome screenshot. Co-authored-by: Cursor <cursoragent@cursor.com>
Cover when the Game-to-Simulator retry applies and when it must not override an explicit non-Game window name. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Warning Review limit reached
Next review available in: 50 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: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds centralized screenshot window-name constants and a resolver that falls back from an unmatched exact “Game” window to “Simulator.” Capture retries with the resolved name, updates related errors and filenames, and logs both requested and effective names. ChangesScreenshot window fallback
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant CaptureRequest
participant CaptureWindowsAsync
participant ScreenshotWindowNameResolver
participant UnityEditorWindows
participant ScreenshotSuccessLogger
CaptureRequest->>CaptureWindowsAsync: request window capture
CaptureWindowsAsync->>ScreenshotWindowNameResolver: resolve requested name
ScreenshotWindowNameResolver-->>CaptureWindowsAsync: Game or Simulator
CaptureWindowsAsync->>UnityEditorWindows: search effective window
UnityEditorWindows-->>CaptureWindowsAsync: matching window result
CaptureWindowsAsync->>ScreenshotSuccessLogger: log requested and effective names
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
Route CaptureWindowsAsync through ResolveCaptureWindowName so production and tests share one path, and report neither Game nor Simulator when the fallback lookup also returns empty. Co-authored-by: Cursor <cursoragent@cursor.com>
2454e40
into
feature/simulator-view-support
There was a problem hiding this comment.
🧹 Nitpick comments (1)
Packages/src/Editor/FirstPartyTools/Screenshot/ScreenshotUseCase.cs (1)
259-276: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUtilize the
ResolveCaptureWindowNamehelper.You have explicitly defined and unit-tested
ScreenshotWindowNameResolver.ResolveCaptureWindowName, but it is bypassed here in favor of manually assigning the fallback window name. Consider using the helper to eliminate duplicate logic.♻️ Proposed refactor
- string captureWindowName = request.WindowName; - if (ScreenshotWindowNameResolver.ShouldFallbackToSimulator( - request.WindowName, - request.MatchMode, - windows.Length)) - { - // why: Device Simulator replaces the Game tab, so the default "Game" title miss should retry Simulator - captureWindowName = UnityCliLoopConstants.SCREENSHOT_SIMULATOR_WINDOW_NAME; - windows = EditorWindowCaptureUtility.FindWindowsByName(captureWindowName, request.MatchMode); - if (windows.Length > 0) - { - VibeLogger.LogInfo( - "screenshot_window_fallback_simulator", - $"Window '{request.WindowName}' not found; capturing '{captureWindowName}' instead", - correlationId: correlationId - ); - } - } + string captureWindowName = ScreenshotWindowNameResolver.ResolveCaptureWindowName( + request.WindowName, + request.MatchMode, + windows.Length); + + if (captureWindowName != request.WindowName) + { + // why: Device Simulator replaces the Game tab, so the default "Game" title miss should retry Simulator + windows = EditorWindowCaptureUtility.FindWindowsByName(captureWindowName, request.MatchMode); + if (windows.Length > 0) + { + VibeLogger.LogInfo( + "screenshot_window_fallback_simulator", + $"Window '{request.WindowName}' not found; capturing '{captureWindowName}' instead", + correlationId: correlationId + ); + } + }🤖 Prompt for 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. In `@Packages/src/Editor/FirstPartyTools/Screenshot/ScreenshotUseCase.cs` around lines 259 - 276, Update the screenshot window fallback logic in the surrounding capture flow to use ScreenshotWindowNameResolver.ResolveCaptureWindowName instead of manually assigning UnityCliLoopConstants.SCREENSHOT_SIMULATOR_WINDOW_NAME. Preserve the existing window lookup, fallback logging, and capture behavior while routing name selection through the tested helper.
🤖 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.
Nitpick comments:
In `@Packages/src/Editor/FirstPartyTools/Screenshot/ScreenshotUseCase.cs`:
- Around line 259-276: Update the screenshot window fallback logic in the
surrounding capture flow to use
ScreenshotWindowNameResolver.ResolveCaptureWindowName instead of manually
assigning UnityCliLoopConstants.SCREENSHOT_SIMULATOR_WINDOW_NAME. Preserve the
existing window lookup, fallback logging, and capture behavior while routing
name selection through the tested helper.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: dc6dae54-fb9b-4c6f-b95a-c782cae92193
⛔ Files ignored due to path filters (2)
Assets/Tests/Editor/ScreenshotWindowNameResolverTests.cs.metais excluded by none and included by nonePackages/src/Editor/FirstPartyTools/Screenshot/ScreenshotWindowNameResolver.cs.metais excluded by none and included by none
📒 Files selected for processing (5)
Assets/Tests/Editor/ScreenshotWindowNameResolverTests.csPackages/src/Editor/FirstPartyTools/Screenshot/ScreenshotUseCase.csPackages/src/Editor/FirstPartyTools/Screenshot/ScreenshotWindowNameResolver.csPackages/src/Editor/ToolContracts/ScreenshotSchema.csPackages/src/Editor/ToolContracts/UnityCliLoopConstants.cs
Refs: MasaVault
2026-07-14_シミュレーターモードでのマウスシミュレート調査.mdPR-2 (To-Do 10–12)Summary
--capture-mode windowuses the default window nameGameand no matching tab exists, retry withSimulator.--window-name Simulatorif both miss.UnityCliLoopConstants; schema default uses the same constant.User Impact
uloop screenshot --capture-mode window(no--window-name) captures the Simulator chrome instead of returning 0 screenshots.Test plan
dist/darwin-arm64/uloop compile→ 0/0ScreenshotWindowNameResolverTestsEditMode → passed--capture-mode windowreturnsSimulator_*.pngfeature/simulator-view-support(workflows only formain/v3-beta). Full GHA on the final umbrella →v3-betaPR.Made with Cursor