Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ jobs:
}
& ./scripts/cowork-inference/test-diagnostics.ps1
& ./scripts/cowork-inference/test-prepare-task.ps1
& ./scripts/cowork-inference/test-task-waits.ps1
- name: Download and verify the approved Claude installer
shell: pwsh
run: ./scripts/cowork-inference/download-desktop.ps1
Expand Down
9 changes: 9 additions & 0 deletions scripts/cowork-inference/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ through Windows UI Automation. `--force-renderer-accessibility` exposes the app'
accessible controls. Controls are polled until enabled and visible, with a 60-second deadline per
transition. No preliminary launch or virtualization check is needed.

On a Windows task control timeout, `result.json` includes `waitFailure`: the requested
labels, wait budget, scan count, and elapsed milliseconds before and after the failure
snapshot. `wait-failed.json` captures the actual subtree searched, including native folder
dialogs. Compare those timings with the snapshot when an expected control appears there;
its presence after the wait alone does not establish when it became available.
If snapshot collection fails, `snapshotError` records its exception class and the original
control timeout remains the failure. `test-task-waits.ps1` checks ready controls, missing
controls, and failed snapshots with only the UI Automation boundary substituted.

The test installs UG from the checkout, runs `ug configure` with the existing
`UCODE_TEST_WORKSPACE` and `DATABRICKS_BEARER` CI secrets, and checks the generated
gateway profile. UG detects the installed Windows MSIX package and executable,
Expand Down
46 changes: 46 additions & 0 deletions scripts/cowork-inference/test-task-waits.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
$ErrorActionPreference = 'Stop'
$tokens = $null
$errors = $null
$source = [System.Management.Automation.Language.Parser]::ParseFile(
(Join-Path $PSScriptRoot 'test-task.ps1'), [ref]$tokens, [ref]$errors)
if ($errors.Count) { throw ($errors | Out-String) }
$definition = $source.Find({
param($node)
$node -is [System.Management.Automation.Language.FunctionDefinitionAst] -and $node.Name -eq 'Wait-Control'
}, $true)
Invoke-Expression $definition.Extent.Text

# UI Automation is the external boundary; execute the real wait and evidence handling.
function Find-Control { param($Names, $Root) return $script:control }
function Save-UI {
param($Name, $Root)
if ($Name -ne 'wait-failed' -or -not [object]::ReferenceEquals($Root, $script:expectedRoot)) {
throw 'Wrong snapshot subtree'
}
if ($script:failSnapshot) { throw [InvalidOperationException]::new('Closed UI root') }
$script:snapshotSaved = $true
}

$script:control = [pscustomobject]@{ Name = 'ready' }
$report = [ordered]@{}
if ((Wait-Control -Names @('ready') -Seconds 0) -ne $script:control -or $report.Contains('waitFailure')) {
throw 'Ready control did not return without failure evidence'
}
$script:control = $null
$script:expectedRoot = [pscustomobject]@{ Name = 'native folder dialog' }
foreach ($script:failSnapshot in @($false, $true)) {
$report = [ordered]@{}
$script:snapshotSaved = $false
$message = ''
try { Wait-Control -Names @('missing') -Seconds 0 -Root $script:expectedRoot }
catch { $message = $_.Exception.Message }
if ($message -ne 'Control not ready: missing') { throw "Timeout replaced by: $message" }
$failure = ($report | ConvertTo-Json -Depth 8 | ConvertFrom-Json).waitFailure
if ($failure.names[0] -ne 'missing' -or $failure.budgetSeconds -ne 0 -or $failure.scans -ne 1 -or
$failure.elapsedMilliseconds -lt 0 -or $failure.snapshotCompletedMilliseconds -lt $failure.elapsedMilliseconds) {
throw 'Missing or inconsistent wait evidence'
}
if ($script:failSnapshot) {
if ($failure.snapshotError -ne 'InvalidOperationException') { throw 'Missing snapshot error class' }
} elseif (-not $script:snapshotSaved) { throw 'Failure snapshot was not saved' }
}
13 changes: 12 additions & 1 deletion scripts/cowork-inference/test-task.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,23 @@ function Find-Control {
function Wait-Control {
param([string[]]$Names, [int]$Seconds = 60, $Root = $script:window)
$deadline = [DateTime]::UtcNow.AddSeconds($Seconds)
$timer = [Diagnostics.Stopwatch]::StartNew()
$scans = 0
do {
$scans++
$control = Find-Control -Names $Names -Root $Root
if ($control) { return $control }
Start-Sleep -Milliseconds 500
} until ([DateTime]::UtcNow -ge $deadline)
Save-UI 'wait-failed'
$report.waitFailure = [ordered]@{
names = $Names
budgetSeconds = $Seconds
scans = $scans
elapsedMilliseconds = $timer.ElapsedMilliseconds
}
try { Save-UI 'wait-failed' -Root $Root }
catch { $report.waitFailure.snapshotError = $_.Exception.GetType().Name }
$report.waitFailure.snapshotCompletedMilliseconds = $timer.ElapsedMilliseconds
throw "Control not ready: $($Names -join ', ')"
}

Expand Down
Loading