Repository navigation
chore: simplify CLI installation detection internals - #1642
Conversation
Pin ordered stdout capture, exit-code reporting, missing executable handling, and the already-exited cleanup race before consolidating the process runner.
Make one runner own process startup, output capture, timeout cleanup, and exit reporting while the detector keeps shell and version interpretation policy.
📝 WalkthroughWalkthroughThis PR extracts process execution logic from ChangesCLI detection command runner extraction
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant CliInstallationDetector
participant CliDetectionCommandRunner
participant Process
CliInstallationDetector->>CliDetectionCommandRunner: Execute(startInfo, ct)
CliDetectionCommandRunner->>Process: Start() and redirect stdout/stderr
Process-->>CliDetectionCommandRunner: OutputDataReceived (stdout lines)
alt process completes within timeout
CliDetectionCommandRunner->>Process: WaitForExit() to flush buffers
CliDetectionCommandRunner-->>CliInstallationDetector: CliDetectionCommandResult(lines, exitCode)
else timeout or cancellation
CliDetectionCommandRunner->>Process: KillProcessIfRunning()
CliDetectionCommandRunner-->>CliInstallationDetector: null
end
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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.
🧹 Nitpick comments (1)
Packages/src/Editor/Infrastructure/CLI/CliInstallationDetector.cs (1)
490-510: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftKeep unexpected runner failures fail-fast.
CliDetectionCommandRunner.Executealready maps expected “no result” cases tonull; this broad catch now also hides unexpected runner bugs introduced by the extraction. Please narrow this to the expected process/detection exceptions, or let unexpected exceptions propagate.Based on learnings, avoid broad defensive try-catch for unexpected exceptions and catch only expected, domain-specific exceptions at the appropriate layer.
🤖 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/Infrastructure/CLI/CliInstallationDetector.cs` around lines 490 - 510, The broad try/catch in CliInstallationDetector’s CLI version detection helper is swallowing unexpected bugs from CliDetectionCommandRunner.Execute, which should fail fast instead of being hidden. Narrow the catch in the detection path to only the expected process/detection exceptions handled by Execute, or remove it so unexpected exceptions propagate, while keeping the existing null-return handling for normal “no result” cases.Source: Learnings
🤖 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/Infrastructure/CLI/CliInstallationDetector.cs`:
- Around line 490-510: The broad try/catch in CliInstallationDetector’s CLI
version detection helper is swallowing unexpected bugs from
CliDetectionCommandRunner.Execute, which should fail fast instead of being
hidden. Narrow the catch in the detection path to only the expected
process/detection exceptions handled by Execute, or remove it so unexpected
exceptions propagate, while keeping the existing null-return handling for normal
“no result” cases.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: dfbc9111-ab10-449c-adcc-fb1290150dd8
⛔ Files ignored due to path filters (2)
Assets/Tests/Editor/CliDetectionCommandRunnerTests.cs.metais excluded by none and included by nonePackages/src/Editor/Infrastructure/CLI/CliDetectionCommandRunner.cs.metais excluded by none and included by none
📒 Files selected for processing (4)
Assets/Tests/Editor/CliDetectionCommandRunnerTests.csAssets/Tests/Editor/CliInstallationDetectorTests.csPackages/src/Editor/Infrastructure/CLI/CliDetectionCommandRunner.csPackages/src/Editor/Infrastructure/CLI/CliInstallationDetector.cs
💤 Files with no reviewable changes (1)
- Assets/Tests/Editor/CliInstallationDetectorTests.cs
|
CodeRabbit nit disposition: no code change. The broad catch remains at the external process boundary, where it logs the failure and returns the existing explicit |
Summary
User Impact
Changes
CliDetectionCommandRunneras the sole owner of detection process startup, ordered stdout capture, stderr draining, cancellation registration, timeout kill, output flush, disposal, and exit-code reporting.CliInstallationDetectorretains its two existing policies: login-shell marker output preserves line boundaries and ignores the outer shell exit code, while direct version probes concatenate lines and reject non-zero or empty output.null, redirected output is constructed as a runner precondition, and the caller-owned cancellation token source remains live during execution; avoiding a mutable start/wait session keeps a single execution path.Verification
CliDetectionCommandRunnerTests: 4/4 passed.CliInstallationDetectorTests: 14/14 passed.CliSetupApplicationServiceTests: 4/4 passed.CliPathSetupFlowTests: 4/4 passed.StaticFacadeStateGuardTests: 20/20 passed.git diff --check origin/v3-beta...HEAD: passed.Compatibility