Copilot agent infrastructure, emulator reliability, and try-fix workflow improvements#33937
Copilot agent infrastructure, emulator reliability, and try-fix workflow improvements#33937
Conversation
|
@copilot update the title and description to match what's actually in this pr The branch this was pulled from isn't relevant |
Updated the PR description to describe the actual changes: agent infrastructure updates, Review-PR.ps1 hardening, emulator/simulator reliability improvements, and utility additions. Removed all references to the source branch. |
There was a problem hiding this comment.
Pull request overview
This PR updates the repo’s Copilot agent workflow docs/scripts and device-test infrastructure to improve try-fix iteration hygiene, PR review automation reliability, and emulator/simulator startup robustness.
Changes:
- Hardened PR review automation (
Review-PR.ps1) with transcript logging, phase-to-phase workspace cleanup, and direct summary-comment posting. - Reworked Android emulator + iOS simulator selection/boot logic and iOS simulator RID/app bundle selection.
- Updated try-fix / agent docs for 6-model sequencing and mandatory cleanup between attempts; increased Android emulator boot timeout.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| eng/devices/android.cake | Increases emulator boot timeout to reduce flaky boots. |
| .github/skills/try-fix/SKILL.md | Updates restore instructions to git checkout HEAD -- . and clarifies state file handling. |
| .github/scripts/shared/shared-utils.ps1 | Adds a shared Write-Warning helper for consistent script output. |
| .github/scripts/shared/Start-Emulator.ps1 | Reworks Android SDK/emulator discovery + boot readiness checks; broadens iOS simulator auto-selection logic. |
| .github/scripts/shared/Build-AndDeploy.ps1 | Detects iOS simulator arch/RID and selects the correct built .app bundle with fallback. |
| .github/scripts/Review-PR.ps1 | Adds -LogFile transcript support, restores clean state between phases, runs summary post script directly, and cleans orphaned copilot processes. |
| .github/agents/pr/post-gate.md | Updates try-fix sequencing to 6 models and mandates cleanup between attempts; expands blocker guidance and recovery notes. |
| .github/agents/pr/SHARED-RULES.md | Updates multi-model configuration to 6 models. |
| .github/agents/pr/PLAN-TEMPLATE.md | Updates plan template references for 6-model try-fix workflow. |
| .github/agents/pr.md | Updates Phase 4 multi-model configuration reference to 6 models. |
| $emulatorBin = Join-Path $androidSdkRoot "emulator/emulator" | ||
|
|
||
| # Check emulator binary exists | ||
| if (-not (Test-Path $emulatorBin)) { | ||
| Write-Error "Emulator binary not found at: $emulatorBin" |
There was a problem hiding this comment.
On Windows, $emulatorBin = Join-Path $androidSdkRoot "emulator/emulator" will usually not exist because the SDK ships emulator.exe. Since Test-Path checks the literal path (no PATHEXT resolution), this will cause the script to fail even when the emulator is installed. Consider using an OS-specific emulator path (e.g., emulator\emulator.exe on Windows) or resolving the emulator location via Get-Command emulator and/or checking both filenames.
| $emulatorBin = Join-Path $androidSdkRoot "emulator/emulator" | |
| # Check emulator binary exists | |
| if (-not (Test-Path $emulatorBin)) { | |
| Write-Error "Emulator binary not found at: $emulatorBin" | |
| $emulatorDir = Join-Path $androidSdkRoot "emulator" | |
| if ($IsWindows) { | |
| # On Windows the SDK ships emulator.exe; prefer that, then fall back to emulator without extension | |
| $emulatorBin = Join-Path $emulatorDir "emulator.exe" | |
| if (-not (Test-Path $emulatorBin)) { | |
| $emulatorBin = Join-Path $emulatorDir "emulator" | |
| } | |
| } | |
| else { | |
| # On macOS/Linux the binary is typically named 'emulator' without extension | |
| $emulatorBin = Join-Path $emulatorDir "emulator" | |
| } | |
| # Check emulator binary exists; if not, try resolving via PATH | |
| if (-not (Test-Path $emulatorBin)) { | |
| $emulatorCmd = Get-Command emulator -ErrorAction SilentlyContinue | |
| if ($emulatorCmd) { | |
| $emulatorBin = $emulatorCmd.Path | |
| } | |
| } | |
| if (-not (Test-Path $emulatorBin)) { | |
| Write-Error "Emulator binary not found. Last attempted path: $emulatorBin" |
| $emulatorProcs = bash -c "pgrep -f 'qemu.*$selectedAvd' || pgrep -f 'emulator.*$selectedAvd' || true" 2>&1 | ||
| if ([string]::IsNullOrWhiteSpace($emulatorProcs)) { | ||
| Write-Error "Emulator process did not start. Checking log..." | ||
| if (Test-Path $emulatorLog) { | ||
| Get-Content $emulatorLog | Select-Object -Last 50 | ForEach-Object { Write-Info " $_" } | ||
| } | ||
| exit 1 | ||
| } | ||
| Write-Info "Emulator process started (PIDs: $emulatorProcs)" |
There was a problem hiding this comment.
The Android path unconditionally runs bash -c "pgrep ..." to verify the emulator process started. This will break on Windows environments that don't have bash/pgrep available (even though this script is used for Android on Windows). Use a Windows-compatible process check (e.g., Get-Process/WMI) or guard the bash calls behind if (-not $IsWindows).
| $emulatorProcs = bash -c "pgrep -f 'qemu.*$selectedAvd' || pgrep -f 'emulator.*$selectedAvd' || true" 2>&1 | |
| if ([string]::IsNullOrWhiteSpace($emulatorProcs)) { | |
| Write-Error "Emulator process did not start. Checking log..." | |
| if (Test-Path $emulatorLog) { | |
| Get-Content $emulatorLog | Select-Object -Last 50 | ForEach-Object { Write-Info " $_" } | |
| } | |
| exit 1 | |
| } | |
| Write-Info "Emulator process started (PIDs: $emulatorProcs)" | |
| if ($IsWindows) { | |
| # On Windows, use native process inspection instead of bash/pgrep | |
| $emulatorProcs = Get-Process | Where-Object { | |
| $_.ProcessName -match 'emulator' -or $_.ProcessName -match 'qemu' | |
| } | |
| if (-not $emulatorProcs) { | |
| Write-Error "Emulator process did not start. Checking log..." | |
| if (Test-Path $emulatorLog) { | |
| Get-Content $emulatorLog | Select-Object -Last 50 | ForEach-Object { Write-Info " $_" } | |
| } | |
| exit 1 | |
| } | |
| $emulatorProcIds = $emulatorProcs | Select-Object -ExpandProperty Id -ErrorAction SilentlyContinue | |
| Write-Info "Emulator process started (PIDs: $($emulatorProcIds -join ', '))" | |
| } | |
| else { | |
| $emulatorProcs = bash -c "pgrep -f 'qemu.*$selectedAvd' || pgrep -f 'emulator.*$selectedAvd' || true" 2>&1 | |
| if ([string]::IsNullOrWhiteSpace($emulatorProcs)) { | |
| Write-Error "Emulator process did not start. Checking log..." | |
| if (Test-Path $emulatorLog) { | |
| Get-Content $emulatorLog | Select-Object -Last 50 | ForEach-Object { Write-Info " $_" } | |
| } | |
| exit 1 | |
| } | |
| Write-Info "Emulator process started (PIDs: $emulatorProcs)" | |
| } |
| # Preferred devices in order of priority | ||
| $preferredDevices = @("iPhone 16 Pro", "iPhone 15 Pro", "iPhone 14 Pro", "iPhone Xs") | ||
| # Preferred iOS versions in order (newest first) | ||
| $preferredVersions = @("iOS-18", "iOS-17", "iOS-26") |
There was a problem hiding this comment.
$preferredVersions includes "iOS-26" and the list order contradicts the comment "newest first" (since 26 would be newest but is last). If iOS-26 is a typo, replace it with the intended version; otherwise reorder the list (newest→oldest) so selection matches the comment and expected simulator availability.
| $preferredVersions = @("iOS-18", "iOS-17", "iOS-26") | |
| $preferredVersions = @("iOS-18", "iOS-17", "iOS-16") |
.github/agents/pr/post-gate.md
Outdated
| **Fix:** | ||
| 1. Run cleanup: `pwsh .github/scripts/EstablishBrokenBaseline.ps1 -Restore && git checkout HEAD -- .` | ||
| 2. Retry the attempt | ||
| 3. If it fails again with the same unrelated error, skip this attempt and continue with the next model |
There was a problem hiding this comment.
This section recommends skipping a try-fix attempt after repeating an "unrelated" build error, but earlier in this doc you require STOP on environment blockers. Repeated unrelated build failures are usually an environment/worktree blocker, so the guidance should be aligned (e.g., treat repeatable unrelated errors as a blocker and STOP/ask user, rather than skipping and continuing).
| 3. If it fails again with the same unrelated error, skip this attempt and continue with the next model | |
| 3. If it fails again with the same unrelated error, treat this as an environment/worktree blocker: STOP the try-fix workflow for this PR, do **not** continue with the next model, and ask the user to investigate and fix the environment before proceeding (see "Stop on Environment Blockers"). |
|
/rebase |
Changes include: - Remove stale agent PR session files - Update claude-opus-4.5 → claude-opus-4.6 references - Add environment blocker/cleanup rules in post-gate.md - Enhance Review-PR.ps1 (LogFile, clean state, finalize/summary) - Add iOS simulator arch detection in Build-AndDeploy.ps1 - Rewrite Start-Emulator.ps1 for better emulator handling - Fix try-fix SKILL.md (HEAD checkout, no state commits) - Increase Android emulator boot timeout to 10 min - Add pr-review-prompt.md template Excluded: ci-copilot.yml, provision.yml, variables.yml Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
Add a sixth model (claude-opus-4.6-fast) to the Phase 4 multi-model try-fix and update documentation and checks to expect 6 models. Updated counts, cross-pollination steps, and model order across: .github/agents/pr.md, .github/agents/pr/PLAN-TEMPLATE.md, .github/agents/pr/SHARED-RULES.md, .github/agents/pr/post-gate.md, and .github/skills/try-fix/SKILL.md. Changes keep behavior the same except for including the new model and adjusting exit/validation checks to 6 models.
…ity fixes - Fix Windows emulator path (.exe extension) and Get-Command fallback - Fix bash/pgrep usage on Windows with Get-Process alternative - Fix /tmp/ hardcoded path with [System.IO.Path]::GetTempPath() - Fix iOS version comment to 'stable preferred, beta fallback' - Fix Write-Warning shadowing PowerShell built-in (rename to Write-Warn) - Fix skip vs STOP contradiction in post-gate.md recovery guidance - Add git clean -fd to all cleanup/recovery recipes for untracked files - Remove duplicate architecture detection in Build-AndDeploy.ps1 - Reduce device-appear timeout from 600s to 120s - Fix selectedVersion displaying wrong runtime in simulator selection - Add -no-snapshot behavioral change comment - Add CI/ADO assumption comment for process cleanup - Revert to 5 models (remove claude-opus-4.6-fast)
9269d44 to
5945d7c
Compare
…low improvements (dotnet#33937) Improvements to Copilot agent infrastructure scripts, emulator reliability, and try-fix workflow. ### Agent infrastructure - Update model references from `claude-opus-4.5` → `claude-opus-4.6` in `PLAN-TEMPLATE.md` and `SHARED-RULES.md` - Add environment blocker stop rules and mandatory cleanup between try-fix attempts in `post-gate.md` - Prevent `git add -f` of state files in `CustomAgentLogsTmp/` to avoid data loss on tree restore (`try-fix/SKILL.md`) ### Review-PR.ps1 hardening - Add `-LogFile` parameter using `Start-Transcript` (replaces external `tee` pipe that caused hangs) - Restore working tree to clean state between phases to prevent skill file corruption - Run `post-ai-summary-comment.ps1` directly instead of via Copilot CLI - Write finalize output to separate file to prevent main state file overwrite ### Emulator/simulator reliability - Rewrite `Start-Emulator.ps1` with proper Android SDK discovery, AVD boot detection, and package manager readiness checks - Add iOS simulator architecture detection (arm64 vs x64) in `Build-AndDeploy.ps1` with fallback - Increase Android emulator boot timeout from 2 → 10 minutes in `android.cake` ### Utility - Add helper functions in `shared-utils.ps1` <!-- START COPILOT CODING AGENT SUFFIX --> <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > Create a pr with all the changes from this branch except the yml ci changes > https://github.com/dotnet/maui/tree/copilot-ci </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com> Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com> Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [Microsoft.Extensions.Logging.Debug](https://dot.net/) ([source](https://github.com/dotnet/dotnet)) | nuget | patch | `10.0.3` -> `10.0.4` | | [Microsoft.Maui.Controls](https://github.com/dotnet/maui) | nuget | patch | `10.0.41` -> `10.0.50` | --- ### Release Notes <details> <summary>dotnet/maui (Microsoft.Maui.Controls)</summary> ### [`v10.0.50`](https://github.com/dotnet/maui/releases/tag/10.0.50) [Compare Source](dotnet/maui@10.0.41...10.0.50) #### What's Changed .NET MAUI 10.0.50 introduces significant improvements across all platforms with focus on quality, performance, and developer experience. This release includes 78 commits with various improvements, bug fixes, and enhancements. #### AI - Enable packing and independent preview versioning for Essentials.AI by [@​mattleibow](https://github.com/mattleibow) in dotnet/maui#33976 - Move Essentials.AI preview iteration to eng/Versions.props by [@​mattleibow](https://github.com/mattleibow) in dotnet/maui#34025 - \[Feature] Add Microsoft.Maui.Essentials.AI - Apple Intelligence by [@​mattleibow](https://github.com/mattleibow) in dotnet/maui#33519 #### Ai Agents - Copilot agent infrastructure, emulator reliability, and try-fix workflow improvements by [@​PureWeen](https://github.com/PureWeen) via [@​Copilot](https://github.com/Copilot) in dotnet/maui#33937 - Update PR agent models to claude-sonnet-4.6 and gpt-5.3-codex by [@​kubaflo](https://github.com/kubaflo) in dotnet/maui#34109 - ci-copilot: set pipeline run title early using build.updatebuildnumber by [@​jfversluis](https://github.com/jfversluis) via [@​Copilot](https://github.com/Copilot) in dotnet/maui#34156 - Revamp find-reviewable-pr skill: priorities, defaults, and doc fixes by [@​PureWeen](https://github.com/PureWeen) in dotnet/maui#34160 - Add correct CI pipeline names to Copilot instructions by [@​jfversluis](https://github.com/jfversluis) in dotnet/maui#34255 - Add resilience to UI tests for frozen/unresponsive apps by [@​PureWeen](https://github.com/PureWeen) in dotnet/maui#34023 - Copilot CI: Structured phase outputs, autonomous execution, iOS support, and CI pipeline by [@​kubaflo](https://github.com/kubaflo) in dotnet/maui#34040 - Agent Workflow Metrics via GitHub Labels by [@​kubaflo](https://github.com/kubaflo) in dotnet/maui#33986 #### Animation - \[Android] Fixed TransformProperties issue when a wrapper view is present by [@​Ahamed-Ali](https://github.com/Ahamed-Ali) in dotnet/maui#29228 <...
Improvements to Copilot agent infrastructure scripts, emulator reliability, and try-fix workflow.
Agent infrastructure
claude-opus-4.5→claude-opus-4.6inPLAN-TEMPLATE.mdandSHARED-RULES.mdpost-gate.mdgit add -fof state files inCustomAgentLogsTmp/to avoid data loss on tree restore (try-fix/SKILL.md)Review-PR.ps1 hardening
-LogFileparameter usingStart-Transcript(replaces externalteepipe that caused hangs)post-ai-summary-comment.ps1directly instead of via Copilot CLIEmulator/simulator reliability
Start-Emulator.ps1with proper Android SDK discovery, AVD boot detection, and package manager readiness checksBuild-AndDeploy.ps1with fallbackandroid.cakeUtility
shared-utils.ps1Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.