Skip to content

fix: bound Go external OS commands and propagate Ctrl+C cancellation#1738

Merged
hatayama merged 4 commits into
v3-betafrom
feature/go-external-command-timeouts
Jul 13, 2026
Merged

fix: bound Go external OS commands and propagate Ctrl+C cancellation#1738
hatayama merged 4 commits into
v3-betafrom
feature/go-external-command-timeouts

Conversation

@hatayama

@hatayama hatayama commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

Refs: 2026-07-13_uloopハング可能性の全数調査結果.md §1 feature/go-external-command-timeouts

Eliminates the remaining indefinitely-blocking Go CLI paths identified in the hang survey:

  • PR 2-1: Cap ps / PowerShell Get-CimInstance process enumeration at 10s (unityprocess, tool_readiness)
  • PR 2-2: Cap osascript / PowerShell focus commands at 10s and bound connection-retry focus rescue
  • PR 2-3: Wire signal.NotifyContext through dispatcher and project-runner main so Ctrl+C cancels in-flight work

Test plan

  • go test for cli/common/unityprocess, cli/common/clicore, cli/project-runner/internal/projectrunner
  • scripts/check-go-cli.sh (note: TestCommandHelpUsesWatchToolSchemaForDefaultWatchCommands also fails on clean v3-beta checkout here — unrelated to this change)
  • CI green on PR

Made with Cursor

Review in cubic

hatayama and others added 3 commits July 13, 2026 14:09
ps and PowerShell Get-CimInstance can hang indefinitely when WMI stalls.
Apply a 10-second cap inside unityprocess and use the same bound when
tool readiness classifies a live Unity process after timeout.

Co-authored-by: Cursor <cursoragent@cursor.com>
osascript and PowerShell focus calls can hang on permission dialogs and
compound Unity recovery stalls. Cap them at 10 seconds in unityprocess
and bound connection-retry focus rescue with the same deadline.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use signal.NotifyContext in dispatcher and project-runner main so
in-flight work receives cancellation when the user interrupts the CLI.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c6ce8678-26e3-4060-903b-e186f8ea208d

📥 Commits

Reviewing files that changed from the base of the PR and between a086ac9 and 23fba8b.

📒 Files selected for processing (13)
  • cli/common/clicore/tool_readiness.go
  • cli/common/clicore/tool_readiness_test.go
  • cli/common/unityprocess/focus_darwin.go
  • cli/common/unityprocess/focus_windows.go
  • cli/common/unityprocess/process.go
  • cli/common/unityprocess/timeouts.go
  • cli/common/unityprocess/timeouts_test.go
  • cli/dispatcher/cmd/dispatcher/main.go
  • cli/dispatcher/shared-inputs-stamp.json
  • cli/project-runner/cmd/project-runner/main.go
  • cli/project-runner/internal/projectrunner/connection_retry.go
  • cli/project-runner/internal/projectrunner/connection_retry_test.go
  • cli/project-runner/shared-inputs-stamp.json

📝 Walkthrough

Walkthrough

The change adds bounded contexts for Unity process listing and focus commands, validates their deadlines, and propagates interrupt and termination signals through dispatcher and project-runner entrypoints.

Changes

Timeouts and graceful shutdown

Layer / File(s) Summary
Timeout contract and validation
cli/common/unityprocess/timeouts.go, cli/common/unityprocess/timeouts_test.go
Adds 10-second process-list and focus timeouts, a shared timeout helper, and tests for parent and background context deadlines.
Process listing and readiness lookup
cli/common/unityprocess/process.go, cli/common/clicore/tool_readiness.go, cli/common/clicore/tool_readiness_test.go
Bounds macOS and Windows process enumeration and validates the timeout context used by readiness checks.
Focus command execution
cli/common/unityprocess/focus_*, cli/project-runner/internal/projectrunner/connection_retry.*
Bounds focus and restore commands on macOS and Windows, including retry focus attempts, with deadline coverage.
Signal-aware CLI entrypoints
cli/dispatcher/cmd/dispatcher/main.go, cli/project-runner/cmd/project-runner/main.go, cli/*/shared-inputs-stamp.json
Passes interrupt and SIGTERM-aware contexts into dispatcher and project-runner execution and updates generated input hashes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: bounding OS commands and propagating Ctrl+C cancellation.
Description check ✅ Passed The description matches the changeset and objectives, covering command timeouts, focus rescue, and signal-aware cancellation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/go-external-command-timeouts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

After signal.NotifyContext cancels the root context, call stop again so
a second interrupt exits immediately instead of being swallowed.

Co-authored-by: Cursor <cursoragent@cursor.com>
@hatayama hatayama merged commit ddb0581 into v3-beta Jul 13, 2026
10 checks passed
@hatayama hatayama deleted the feature/go-external-command-timeouts branch July 13, 2026 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant