fix(gates): select a character in connected graphical runs

This commit is contained in:
Erik 2026-08-22 13:24:39 +02:00
parent 7a5f96ede5
commit 0b6c6557a8
4 changed files with 107 additions and 2 deletions

View file

@ -160,6 +160,63 @@ function Restore-ConnectedRenderPackGateEnvironment {
}
}
function New-ConnectedGraphicalSessionConfig {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)][object]$State,
[Parameter(Mandatory = $true)][string]$Account,
[string]$HostName = '127.0.0.1',
[ValidateRange(1, 65535)][int]$Port = 9000,
[ValidateRange(0, [int]::MaxValue)][int]$CharacterIndex = 0,
[string]$CredentialEnvironmentVariable = 'ACDREAM_TEST_PASS'
)
if ([string]::IsNullOrWhiteSpace($Account)) {
throw 'Connected graphical session account cannot be empty.'
}
if ([string]::IsNullOrWhiteSpace($HostName)) {
throw 'Connected graphical session host cannot be empty.'
}
if ($CredentialEnvironmentVariable -notmatch '^[A-Za-z_][A-Za-z0-9_]*$') {
throw "Unsafe credential environment-variable name '$CredentialEnvironmentVariable'."
}
$path = Assert-ConnectedGateContainedPath $State.StateDirectory (
Join-Path $State.StateDirectory 'graphical-session.json')
if (Test-Path -LiteralPath $path) {
throw "Connected graphical session config already exists: '$path'."
}
[ordered]@{
version = 1
sessions = @([ordered]@{
id = 'connected-gate'
endpoint = [ordered]@{ host = $HostName; port = $Port }
account = $Account
character = [ordered]@{ index = $CharacterIndex }
credential = [ordered]@{
provider = 'Environment'
reference = $CredentialEnvironmentVariable
}
})
} | ConvertTo-Json -Depth 8 |
Set-Content -LiteralPath $path -Encoding utf8
return $path
}
function Remove-ConnectedGraphicalSessionConfig {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)][object]$State,
[Parameter(Mandatory = $true)][string]$Path
)
$containedPath = Assert-ConnectedGateContainedPath $State.StateDirectory $Path
if (Test-Path -LiteralPath $containedPath -PathType Leaf) {
Remove-Item -LiteralPath $containedPath -Force
}
}
function Get-ConnectedGateBinaryIdentity {
[CmdletBinding()]
param([Parameter(Mandatory = $true)][string]$Repository,