Add PowerShell host UI streaming#48
Conversation
8094900 to
932d7b4
Compare
|
Rebased this branch onto current |
932d7b4 to
9dbe271
Compare
ed9af6d to
4c87c52
Compare
|
I'm sorry, this was smth internal :) But actually, yes, .net8 end of support is November 10, 2026. So perhaps it is time to migrate. |
This reverts commit 80b5205.
4c87c52 to
bf23744
Compare
|
Rebased this PR onto current Local validation after the rebase:
Do you plan to merge this PR, or is there anything else you would like changed first? This one is important for us because it makes PowerShell notebooks usable for the workflows we are actively testing. The sample notebooks we are using include:
For those scenarios, silent long-running cells are very hard to diagnose, and interactive host prompts are a blocker for common PowerShell flows such as |
|
Thanks for the rebase and the validation runs. Before I review this one I want to finish closing out testing on the PRs that merged recently and fix anything that surfaces from that pass. Stacking more on top before that makes the next round of issues harder to attribute. I'll come back to this once that's done. |
| } | ||
|
|
||
| foreach (var info in ps.Streams.Information) | ||
| if (hostOutput is null) |
There was a problem hiding this comment.
Write-Information output is dropped: WriteInformation is a no-op and ps.Streams.Information is skipped when hostOutput is set. Please keep the stream loop and filter records by tag: skip PSHOST (that's Write-Host, already covered by the host UI) and keep the rest. Worth a regression test with Write-Information -InformationAction Continue.
|
The new Unrelated to the above, but should be addressed as well is |
|
|
||
| public override PSHostRawUserInterface RawUI => _rawUI; | ||
|
|
||
| public override bool SupportsVirtualTerminal => true; |
There was a problem hiding this comment.
It's cleaner to set this as false until SGR parsing is implemented. The Emit currently strips the ANSI sequences, so it's easier to just leave them out for now.
Move the PowerShell PSHost adapter under src/Verso.PowerShell/Kernel/Host and switch it to the Verso.PowerShell.Kernel.Host namespace. The adapter is now an internal implementation detail of the PowerShell kernel instead of a separately published Verso.PowerShellHost package. Remove the Verso.PowerShellHost project from the solution and drop the project reference from Verso.PowerShell. Update architecture docs so they describe the host adapter as internal to Verso.PowerShell rather than as a standalone package/project. Validation run outside the sandbox: dotnet build src/Verso.PowerShell/Verso.PowerShell.csproj --no-restore; dotnet build Verso.sln --no-restore; dotnet publish src/Verso.PowerShell/Verso.PowerShell.csproj --no-restore -f net8.0; dotnet publish src/Verso.PowerShell/Verso.PowerShell.csproj --no-restore -f net10.0.
Set SupportsVirtualTerminal to false while host output still strips ANSI escape sequences instead of parsing SGR formatting. This avoids advertising VT support until the host can preserve or render supported ANSI sequences safely. Validation: dotnet build src/Verso.PowerShell/Verso.PowerShell.csproj --no-restore; dotnet test tests/Verso.PowerShell.Tests/Verso.PowerShell.Tests.csproj --no-restore.
Keep processing ps.Streams.Information even when the PowerShell host output callback is active. Filter out only records tagged PSHOST so Write-Host remains covered by the host UI path without duplicating that output, while ordinary Write-Information records are still returned. Add a regression test for Write-Information -InformationAction Continue and update the kernel comment to reflect that the remaining information stream is Write-Information output rather than Write-Host output. Validation: dotnet test tests/Verso.PowerShell.Tests/Verso.PowerShell.Tests.csproj --no-restore; dotnet build src/Verso.PowerShell/Verso.PowerShell.csproj --no-restore.
Subscribe ServerNotebookService to Scaffold.OnCellOutputUpdated and forward those updates through the existing OnOutputUpdated service event so verso serve can repaint running cells when kernels stream host output. Set Scaffold.InputRequester in the server service and add a pending input request flow modelled after extension consent. NotebookPage now displays a Blazor modal for PowerShell input, supports cancellation, and switches to password input when the kernel requests masked input. Add server-flow regression tests for live output forwarding, Read-Host happy path, Read-Host cancellation, password flag propagation, and Write-Information output. The Blazor shared test project now references Verso.Blazor and Verso.PowerShell so these in-process server paths can be exercised directly. Validation: dotnet test tests/Verso.Blazor.Shared.Tests/Verso.Blazor.Shared.Tests.csproj; dotnet test tests/Verso.Blazor.Shared.Tests/Verso.Blazor.Shared.Tests.csproj --no-restore; dotnet test tests/Verso.PowerShell.Tests/Verso.PowerShell.Tests.csproj --no-restore; dotnet build Verso.sln --no-restore.
Run cell and run-all actions now start execution from a background task instead of awaiting the full kernel execution inside the originating Blazor event handler. This keeps the Blazor Server circuit free to process the later Submit, Cancel, and close events from the PowerShell input dialog while a Read-Host cell is waiting for input. Also mark the input dialog buttons as explicit type=button so they cannot accidentally participate in form submission semantics when embedded in future markup. Adds bUnit coverage that the run button returns before a held execution completes, plus submit, cancel, and password-rendering coverage for NotebookInputDialog. Manual verso serve validation confirmed Read-Host, secure Read-Host, prompt cancellation, and Ctrl+C behavior.
Write-Information with -InformationAction Continue can be surfaced twice: PowerShell may render the information record through the host UI while also keeping the same non-PSHOST record in ps.Streams.Information. The previous review fix correctly preserved non-host information records, but did not account for that host-rendered copy. Filter final InformationLines against plain-text outputs already streamed during the same execution, normalizing line endings and trailing newlines before comparison. This keeps Write-Information visible while avoiding a duplicate final output block in verso serve. Strengthens the PowerShell regression test so Write-Information 'info message' -InformationAction Continue must appear exactly once. Manual verso serve validation confirmed the output now renders once.
|
Pushed the review follow-up changes to Summary of what changed:
Validation run locally: dotnet test tests/Verso.PowerShell.Tests/Verso.PowerShell.Tests.csproj --no-restore
dotnet test tests/Verso.Blazor.Shared.Tests/Verso.Blazor.Shared.Tests.csproj --no-restore
dotnet build Verso.sln --no-restore
npm run lintManual Write-Host "before $(Get-Date -Format HH:mm:ss)"
Start-Sleep -Seconds 5
Write-Host "after $(Get-Date -Format HH:mm:ss)"Confirmed $name = Read-Host "Name"
Write-Host "hello $name"Confirmed the input dialog appears, Submit resumes execution, and output contains the submitted value. $secret = Read-Host "Secret" -AsSecureString
Write-Host "done"Confirmed secure input is masked and execution resumes. Write-Information "info message" -InformationAction ContinueConfirmed the message renders once. |
|
Thanks for the follow-up work. Merging now. |

Problem
PowerShell cells that wrote host UI output during long-running execution did not surface that output until the command finished. This made cells that called
Write-Host, prompted withRead-Host, or blocked on longer work feel unresponsive in the notebook UI.PowerShell interactive input also needed a host-to-extension path that can reply while the execution pipeline is still running, without waiting behind the same sequential request queue.
Approach
This PR adds a dedicated
Verso.PowerShellHostadapter and wires it into the PowerShell runspace. The host captures PowerShell UI output and input requests, forwards streamed output through the execution context, and sends input requests to the VS Code extension through the host protocol.The VS Code bridge handles
input/requestnotifications by showing an input box and replying to the host withinput/response.Notable changes
src/Verso.PowerShellHostwith aPSHost,PSHostUserInterface, and raw UI implementation.IExecutionContext.WriteOutputAsync.IExecutionContext.RequestInputAsync.input/requestandinput/response.Validation
npm run lintdotnet build Verso.sln --no-restoreManual checks
PowerShell host output now appears while the command is still running:
Interactive input can be requested from a PowerShell cell:
Review notes
This PR intentionally focuses on PowerShell host UI streaming and input plumbing. Stop/cancel controls are split into a separate PR.