Skip to content

Improve the reliability of Start-AIShell on macOS #362

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 8, 2025

Conversation

daxian-dbw
Copy link
Member

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

PR Summary

This PR significantly improves the reliability of Start-AIShell on macOS, by the following changes:

  1. Create an Python virtual environment for installing iterm2 package. We cannot install iterm2 system-wide because for Python 3.11 or higher versions, it's not allowed to install package system-wide with pip by default -- you will get the "external-managed-environment" error.

  2. The "creating a virtual environment" work is slow and thus pushed to a background thread as soon as the InitAndCleanup type initializes.

  3. Make pypi.org and files.pythonhosted.org as trusted hosts, because a security software may cause issue to SSL validation for access to/from those two endpoints, and thus prevents package installation.

  4. Save the python script for splitting the iterm2 tab in .aish/.cache folder, also version the script file and clean up the old files if there is any. With this change, we avoid writting the same file per Start-AIShell call.

  5. Move StartChannelSetup call to right before the use of the channel name, so that it's less likely to time out comparing to before the change.

  6. The most important change: Update the Python script that creates a splitted pane for current tab to make the new pane directly run aish executable.
    Before the change, we start the pane using the default shell, and then write the aish command as input to the shell using split_pane.async_send_text(...), which was not only slower but also very unreliable:

    • The new pane runs the default shell when starting up, meaning that it will load all profiles of the shell, which could be quite slow for some users. So, it's more likely to cause a timeout for the underlying channel.
    • If pwsh is the default shell, then the async_send_text(...) call won't make PowerShell run the command, but only insert the command to the prompt.

@daxian-dbw daxian-dbw merged commit 282c015 into PowerShell:main Apr 8, 2025
4 checks passed
@daxian-dbw daxian-dbw deleted the mac branch April 8, 2025 04:03
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.

2 participants