From 8b6abe04ba4ef47f721ea5d762931aa17aed94aa Mon Sep 17 00:00:00 2001 From: tisachi Date: Mon, 30 Nov 2026 14:03:33 +0100 Subject: [PATCH] syncTioxyAi.bat: pytanie T/N wypisuje sam cmd, nie PowerShell (w Windows Terminal stdout PS bywa na rurze i tekst bez nowej linii pojawial sie dopiero po Enter), czyszczenie zaleglych klawiszy przed ReadKey, diagnostyka kroku do %TEMP%\tioxyai-ask.log --- client/syncTioxyAi.bat | 25 ++++++++++++++++++++----- tests/ps/test_runSyncBat.ps1 | 2 +- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/client/syncTioxyAi.bat b/client/syncTioxyAi.bat index d1eb988..a13a2ae 100644 --- a/client/syncTioxyAi.bat +++ b/client/syncTioxyAi.bat @@ -325,13 +325,28 @@ if not defined PYTAM goto :pause_na_koncu echo Zeby zobaczyc nowe modele, uruchom ponownie: if "%WAS_VSCODE%"=="1" echo - Visual Studio Code (byl uruchomiony) if "%WAS_OPENCODE%"=="1" echo - OpenCode (byl uruchomiony) +:: Pytanie wypisuje SAM cmd (echo), nie PowerShell. W Windows Terminal +:: (ConPTY) stdout PowerShella bywa na rurze (outRedirect=True), a tekst bez +:: nowej linii wypisany przez Write-Host/Console.Write nie trafia do okna przed +:: blokujacym ReadKey - objaw: "pytanie pojawia sie dopiero po Enter". Echo +:: cmd-a idzie ta sama sciezka co powyzsza lista, ktora jest widoczna od razu. +:: PowerShell robi juz tylko odczyt klawisza, bez wlasnego wypisywania pytania. +echo Uruchomic? [T] tak, [N] nie (Enter = N): +:: Diagnostyka (2026-11-28): stan kroku do %TEMP%\tioxyai-ask.log + stderr PS +:: (2>>), zeby kazdy kolejny "brak pytania" byl udowodniony. KeyAvailable przed +:: ReadKey: zalegly klawisz (np. z odliczania w menu launchera) zostalby +:: zjedzony natychmiast i pytanie znikneloby w ulamek sekundy. +set "ASKLOG=%TEMP%\tioxyai-ask.log" +del /f /q "%ASKLOG%" >nul 2>&1 +echo ASK:was_vscode=%WAS_VSCODE% was_opencode=%WAS_OPENCODE% interpreter=%COMSPEC%>> "%ASKLOG%" powershell -NoProfile -Command ^ - "if (-not [Console]::IsInputRedirected) { Write-Host ' Uruchomic? [T] tak, [N] nie (Enter = N): ' -NoNewline;" ^ + "'ps=' + $PSVersionTable.PSVersion + ' inRedirect=' + [Console]::IsInputRedirected + ' outRedirect=' + [Console]::IsOutputRedirected + ' win=' + [Environment]::OSVersion.Version.ToString() | Out-File -Append -Encoding ascii -LiteralPath $env:TEMP\tioxyai-ask.log;" ^ + "if (-not [Console]::IsInputRedirected) { try { while ([Console]::KeyAvailable) { $null = [Console]::ReadKey($true) } } catch {};" ^ " while ($true) { $k = [Console]::ReadKey($true).Key;" ^ - " if ($k -eq 'T') { Write-Host 'T'; exit 0 };" ^ - " if ($k -eq 'N' -or $k -eq 'Enter' -or $k -eq 'KeypadEnter' -or $k -eq 'Escape') { Write-Host 'N'; exit 1 } }" ^ - "} else { Write-Host ' Uruchomic? T = tak, N = nie (Enter = N): ';" ^ - " $linia = [Console]::ReadLine(); if ($linia -match '^\s*[tT]') { exit 0 } else { exit 1 } }" + " if ($k -eq 'T') { exit 0 };" ^ + " if ($k -eq 'N' -or $k -eq 'Enter' -or $k -eq 'KeypadEnter' -or $k -eq 'Escape') { exit 1 } }" ^ + "} else { $linia = [Console]::ReadLine(); if ($linia -match '^\s*[tT]') { exit 0 } else { exit 1 } }" ^ + " 2>> $env:TEMP\tioxyai-ask.log if not errorlevel 1 ( if "%WAS_VSCODE%"=="1" call :uruchom_vscode if "%WAS_OPENCODE%"=="1" call :uruchom_opencode diff --git a/tests/ps/test_runSyncBat.ps1 b/tests/ps/test_runSyncBat.ps1 index e6d0318..d691802 100644 --- a/tests/ps/test_runSyncBat.ps1 +++ b/tests/ps/test_runSyncBat.ps1 @@ -317,7 +317,7 @@ try { Reset-DummyMarks $result = Invoke-RunSync -TypedKey 'T' -Interactive -Environment $interEnv - Assert-Contains $result.All 'Uruchomic? T = tak, N = nie (Enter = N)' 'prompt pyta o T/N i traktuje Enter jako N' + Assert-Contains $result.All 'Uruchomic? [T] tak, [N] nie (Enter = N)' 'prompt pyta o T/N i traktuje Enter jako N' Assert-Contains $result.All 'Visual Studio Code (byl uruchomiony)' 'pytanie dotyczy Visual Studio Code' Assert-Contains $result.All 'OpenCode (byl uruchomiony)' 'pytanie dotyczy OpenCode' Assert-Contains $result.All 'Visual Studio Code uruchomiony' 'meldunek o starcie VS Code'