Improve the reliability of Start-AIShell
on macOS
#362
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
This PR significantly improves the reliability of
Start-AIShell
on macOS, by the following changes:Create an Python virtual environment for installing
iterm2
package. We cannot installiterm2
system-wide because for Python 3.11 or higher versions, it's not allowed to install package system-wide withpip
by default -- you will get the "external-managed-environment" error.The "creating a virtual environment" work is slow and thus pushed to a background thread as soon as the
InitAndCleanup
type initializes.Make
pypi.org
andfiles.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.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 perStart-AIShell
call.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.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 usingsplit_pane.async_send_text(...)
, which was not only slower but also very unreliable:pwsh
is the default shell, then theasync_send_text(...)
call won't make PowerShell run the command, but only insert the command to the prompt.