Skip to content
Merged
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
## [Unreleased]

### Added
- **ZCode clone launches persist their console output to a log** (2026-11-03):
`launch_zcode_second_instance.ps1` appends every run to
`tools\logs\launch_zcode_<Instance>.log` via a PowerShell transcript (one
file per instance, `-Append` with invocation headers) — the auto-closing
GHOST.bat launcher windows (ZCode [1]-[6]) and the hidden Desktop/Start-menu
shortcut launches no longer lose their output: the ram-guard question and
answer, seed/telegram/sync step results, spawn PID and taskbar stamping are
all reviewable after the fact. Logging is fully best-effort: a transcript
failure prints a yellow warning and never blocks the launch, and
`Stop-Transcript` runs before the ram-guard `exit 0` paths and at script
end. GHOST.bat ZCode [6] also prints the log location after opening the
five windows.
- **ZCode patch [27] waits for you to close the app** (2026-10-31):
`patch_zcode_icon_override.ps1` gained `-WaitForClose` (GHOST.bat ZCode
[27] passes it via `:RunWith`'s new optional extra-args slot) — when
Expand Down
1 change: 1 addition & 0 deletions GHOST.bat
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ if "%~1"=="18" (
call :StartClone "ZCode Orange" "src\windows\launch_zcode_second_instance.ps1" "-Instance Sixth"
echo Five launcher windows opened - each closes automatically when done.
echo First runs clone the Primary profile, so expect a short delay per clone.
echo Launch logs: tools\logs\launch_zcode_Second..Sixth.log - one file per clone.
pause
exit /b
)
Expand Down
24 changes: 24 additions & 0 deletions src/windows/launch_zcode_second_instance.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,26 @@ param(
)
$ErrorActionPreference = 'Stop'

# --- Persistent launch log ---------------------------------------------------
# The launcher windows close automatically when done (GHOST.bat :StartClone) and
# the Desktop/Start-menu shortcuts run this script with -WindowStyle Hidden, so
# the console output is otherwise lost entirely. Append every run to
# tools\logs\launch_zcode_<Instance>.log via a transcript. One file per instance
# keeps the five parallel launchers from interleaving. Everything here is
# best-effort: a logging failure must never block the launch.
try {
$logDir = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..\..\tools\logs'))
New-Item -ItemType Directory -Force -Path $logDir | Out-Null
$script:LaunchLogPath = Join-Path $logDir ("launch_zcode_{0}.log" -f $Instance)
Start-Transcript -Path $script:LaunchLogPath -Append -IncludeInvocationHeader | Out-Null
Write-Host "[log] transcript: $script:LaunchLogPath"
} catch {
Write-Host "[log] transcript disabled: $($_.Exception.Message)" -ForegroundColor Yellow
}
function Stop-LaunchLog {
try { Stop-Transcript | Out-Null } catch { }
}

# Portable paths: work for any Windows user, no hardcoded username.
$UserProfile = $env:USERPROFILE
if ([string]::IsNullOrWhiteSpace($UserProfile)) { $UserProfile = [Environment]::GetFolderPath('UserProfile') }
Expand Down Expand Up @@ -210,13 +230,15 @@ if ($mainsNow.Count -ge $MaxConcurrent) {
$guardAnswer = Read-Host '[ram-guard] Launch anyway? (y/N)'
if ($guardAnswer -notmatch '^[Yy]') {
Write-Host '[ram-guard] Launch cancelled - nothing was started.'
Stop-LaunchLog
exit 0
}
} else {
# Hidden console (Desktop/Start-menu shortcut): the prompt would be
# invisible and hang the launch forever - ask via a dialog instead.
if (-not (Show-GhostRamGuardDialog ($guardLines -join "`n"))) {
Write-Host '[ram-guard] Launch cancelled - nothing was started.'
Stop-LaunchLog
exit 0
}
}
Expand Down Expand Up @@ -782,3 +804,5 @@ if ($targetProc) {
} else {
Write-Host "[taskbar] no window found - identity left to the app's process-level AUMID." -ForegroundColor Yellow
}

Stop-LaunchLog
Loading