Skip to content

Fix code posting on macOS #366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 16, 2025
Merged

Fix code posting on macOS #366

merged 3 commits into from
Apr 16, 2025

Conversation

daxian-dbw
Copy link
Member

@daxian-dbw daxian-dbw commented Apr 16, 2025

PR Summary

Fix #172

This PR fixes the following scenarios on macOS

  1. Running /code post from the AIShell pane to post code to the PowerShell pane
  2. Running Invoke-AIShell -PostCode from the PowerShell to request code to be posted from the AIShell pane.

[NOTE] Now the AIShell module depends on the v2.4.2-beta2 PSReadLine, because a private field was added in PSReadLine to accurately indicate if PSReadLine is initialized and ready to render (PowerShell/PSReadLine#4706).

The AIShell module starts to depend on that field to be more deterministic about if PSReadLine is running and ready. Before this change, we relied on Console.TreatControlCAsInput which is not accurate and may cause race condition: Console.TreatControlCAsInput is set to true, but Initialize(...) is not called yet. Rendering the posted code before initialization could result in corrupted state -- posted code may be rendered on wrong position, or even cause exception.

@daxian-dbw daxian-dbw merged commit 221dcde into PowerShell:main Apr 16, 2025
4 checks passed
@daxian-dbw daxian-dbw deleted the post branch April 16, 2025 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

/code post doesn't insert code to PowerShell prompt on macOS
2 participants