This repository was archived by the owner on Jan 30, 2026. It is now read-only.
Support posting code from the sidecar AIShell to PowerShell with Invoke-AIShell -PostCode#361
Merged
daxian-dbw merged 2 commits intoPowerShell:mainfrom Apr 2, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds new parameter sets to the Invoke-AIShell command to enable posting, copying code, and exiting directly from the AIShell sidecar, and updates the channel to process posted code through the PSReadLine idle event.
- Added new parameter sets (PostCode, CopyCode, Exit) to better handle different code actions.
- Updated the OnPostCode logic in Channel.cs to use the idle event for code insertion when PowerShell is busy, and introduced a new record type for pending code data.
Reviewed Changes
Copilot reviewed 2 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| shell/AIShell.Integration/Commands/InvokeAishCommand.cs | Added new parameter sets and corresponding logic for handling code posting, copying, and exit operations. |
| shell/AIShell.Integration/Channel.cs | Updated PostCode handling with an event-driven mechanism via OnIdleHandler and introduced thread-local storage for pending post code data. |
Files not reviewed (2)
- shell/AIShell.Integration/AIShell.psd1: Language not supported
- shell/AIShell.Integration/AIShell.psm1: Language not supported
StevenBucher98
approved these changes
Apr 2, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
By leveraging the fix in PowerShell/PSReadLine#4442, which handles buffer changes made by a handler of the
OnIdleevent, now we are able to post code to PowerShell from the sidecar AIShell even when PowerShell is busy running a command. The posted code will be inserted into prompt after PowerShell finishes running the current command.-PostCode,-CopyCode, and-Exitparameters toInvoke-AIShellin their separate parameter sets. So, a user don't have to leave the PowerShell session they are working in -- they can send query, copy or post code from the AI response, and exit the sidecar AIShell directly from the PowerShell session.CodePostmessage comes in, theAIShellmodule will check ifPSReadLineis active (whether PSReadLine is running to process user input). If it's active, we revert the current line and insert the posted code; if it's not, then we register a subscriber to theOnIdleevent, and the event handler will insert the posted code when PowerShell becomes idle.