feat: add configurable operator appearance and layout

This commit is contained in:
2026-07-23 11:14:10 +09:00
parent cf117de144
commit f43483533a
34 changed files with 5942 additions and 740 deletions

View File

@@ -0,0 +1,100 @@
[CmdletBinding()]
param()
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$repositoryRoot = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..\..'))
$wrapper = Join-Path $repositoryRoot 'scripts\Invoke-LegacyPackageAppearanceSmoke.ps1'
$harness = Join-Path $repositoryRoot 'scripts\Test-LegacyPackageAppearanceSmoke.mjs'
foreach ($path in @($wrapper, $harness)) {
if (-not [IO.File]::Exists($path)) { throw "Missing appearance smoke file: $path" }
}
$tokens = $null
$errors = $null
[void][Management.Automation.Language.Parser]::ParseFile(
$wrapper,
[ref]$tokens,
[ref]$errors)
if (@($errors).Count -ne 0) { throw 'PowerShell rejected the appearance wrapper.' }
$node = Join-Path $env:USERPROFILE `
'.cache\codex-runtimes\codex-primary-runtime\dependencies\node\bin\node.exe'
if (-not [IO.File]::Exists($node)) {
$node = (Get-Command node.exe -CommandType Application -ErrorAction Stop |
Select-Object -First 1).Source
}
& $node --check $harness
if ($LASTEXITCODE -ne 0) { throw 'Node rejected the appearance harness.' }
$auditJson = & powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass `
-File $wrapper -StaticAudit
if ($LASTEXITCODE -ne 0) { throw 'The appearance static audit failed.' }
$audit = $auditJson | ConvertFrom-Json
if ([string]$audit.result -cne 'PASS' -or
[string]$audit.profile -cne 'operator-appearance-persistence' -or
[string]$audit.packageFlavor -cne 'DebugAppX' -or
[int]$audit.launchCount -ne 2 -or
[int]$audit.phaseCount -ne 2 -or
[int]$audit.physicalSettingsClickCount -ne 2 -or
[int]$audit.physicalSelectCount -ne 6 -or
[int]$audit.inputRetryCount -ne 0 -or
$audit.rawBaselineRecovery -ne $true -or
$audit.packageForceTerminationAllowed -ne $false -or
$audit.sendInputClickAvailable -ne $true -or
$audit.sendInputSelectKeysAvailable -ne $true -or
[int]$audit.inputStructureBytes -ne
[int]$audit.expectedInputStructureBytes -or
[int]$audit.inputStructureBytes -ne $(if ([IntPtr]::Size -eq 8) { 40 } else { 28 }) -or
$audit.inputStructureSizeValidated -ne $true) {
throw 'The appearance audit does not expose the exact two-launch input contract.'
}
$wrapperText = [IO.File]::ReadAllText($wrapper)
$harnessText = [IO.File]::ReadAllText($harness)
foreach ($token in @(
'-BuildFlavor DebugAppX',
'-DefinitionsOnly',
'Start-ExactAppearanceApplication $registration 1',
'Start-ExactAppearanceApplication $registration 2',
'Restore-ExactBaselineSettings',
'[FieldOffset(0)] public MouseInput Mouse',
'[FieldOffset(0)] public HardwareInput Hardware',
'IntPtr.Size == 8 ? 40 : 28',
'operatorSettingsOriginallyAbsent',
'startWorkspaceBehaviorVerifiedBeforeInput -ne $true',
'The application was intentionally left open')) {
if (-not $wrapperText.Contains($token)) { throw "Missing wrapper token: $token" }
}
foreach ($token in @(
'persisted-appearance-after-relaunch',
'persisted start workspace behavior',
'snapshot.dom.activeWorkspace === expectedStartupWorkspace',
'event.isTrusted === true',
'trustedChange: true',
'physicalKeyCounts:',
'A native HTML <select> popup consumes Home/ArrowDown/Enter',
'no input was retried')) {
if (-not $harnessText.Contains($token)) { throw "Missing harness token: $token" }
}
if ($harnessText -match
'postMessage\s*\(\s*\{\s*type:\s*["'']set-operator-appearance' -or
$harnessText.Contains('rpc("Input.dispatchMouseEvent"') -or
$harnessText.Contains('rpc("Input.dispatchKeyEvent"') -or
$harnessText.Contains('trustedKeyDowns.length >= expectedKeyCalls') -or
$wrapperText.Contains('trustedKeyDownCount -lt') -or
$wrapperText -match '(?im)^\s*(?:Stop-Process|taskkill)\b' -or
$wrapperText -match '(?i)C:\\Users\\[^\\]+') {
throw 'The appearance smoke contains a synthetic input or unsafe host contract.'
}
[pscustomobject]@{
result = 'PASS'
launches = 2
physicalSettingsClicks = 2
physicalSelects = 6
persistenceRelaunches = 1
exactRawRestores = 1
inputRetries = 0
} | ConvertTo-Json -Compress

View File

@@ -40,9 +40,12 @@ if ([string]$audit.result -cne 'PASS' -or
[string]$audit.expectedSourceSha256 -cne
'1EE76BC464FB1C44C8B6546E99CDC21C726C0E2C24AD344F5C19AE41BFC0D2F2' -or
[int]$audit.expectedSourceRows -ne 8 -or
[string]$audit.expectedInitialDestinationSha256 -cne
[string]$audit.expectedFreshDestinationSha256 -cne
'13C07BA64587549EDA9C1A694F3DFA19875CB1F888F02C9E071F17C47739E087' -or
[int]$audit.expectedInitialDestinationRows -ne 1 -or
[int]$audit.expectedFreshDestinationRows -ne 1 -or
[string]$audit.expectedImportedDestinationSha256 -cne
'2575C2420800670B0022EBEE819BA3D9640DB14E9552426DF46075D079F1F697' -or
[int]$audit.expectedImportedDestinationRows -ne 9 -or
$audit.sendInputClickAvailable -ne $true -or
$audit.sendInputEscapeAvailable -ne $true) {
throw 'The static audit does not expose the closed input/file contract.'
@@ -79,7 +82,8 @@ foreach ($token in @(
'"choose-operator-folder"',
'"folder-picker-click-cancel"',
'"observe-local-files"',
'receipt?.addedPairCount === 8',
'receipt?.addedPairCount === expectedFirstAdded',
'receipt?.skippedDuplicateCount === expectedFirstSkipped',
'receipt?.addedPairCount === 0',
'process.stdin.unref',
'allowMissingState: true',
@@ -100,6 +104,7 @@ if ($wrapperText -match '(?im)^\s*(?:Remove-Item|Stop-Process|taskkill)\b' -or
physicalClicks = 9
pickerCancels = 3
observations = 4
importAdded = 8
freshImportAdded = 8
alreadyImportedAdded = 0
idempotentAdded = 0
} | ConvertTo-Json -Compress