The ChatGPT patch for Windows Terminal #17978
wochatme
started this conversation in
Show and tell
Replies: 1 comment
-
Wow! What an incredible effort! We'll need a little bit of time to digest and think about this :D |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all,
I would like to show you the "patch" I added to Windows Terminal. Now is AI era, so everyone wants to add AI chatting capability in the terminal. Yes, this idea is good. I know Windows Terminal has a feature called "Terminal Chat", but it is till in early phase. I would like to show you "ZTerm" I made. It is in fact a patch on the top of Windows Terminal.
You can take a quick watch and try in the below link:
https://zterm.ai
The source code is in
https://github.com/wochatme/ZTerm
I would like to explain how I made this patch.
All source files are in ZTerm/msterm folder. There is a document to describe the key technical point I fixed, but it is written in Chinese language. I would like to make an English version in the future. Or you can use AI to translate this document to your mother language.
The class name of the main window of Windows terminal is called "CASCADIA_HOSTING_WINDOW_CLASS". Within this window, the real window that does all the job has a class name "Windows.UI.Composition.DesktopWindowContentBridge". It is a Xaml island window I know little. The child window is full of the client area of the main window. What I want to do is to insert a chatting window on the right side of this Xaml island window. That is easy. Check the code:
It is easy to understand and modify.
After you insert the "chat" child window into the main window, it is your job to do whatever you want to do about AI chatting. It has no relationship with Windows Terminal. I use the below 3 libriaries:
Another import question is: when the user wants to ask the help from AI, AI should "see" the text data on the screen to understand what trouble the user is facing. So how to capture the text data on the current active terminal/pane is a thing to fix. It blocked me two weeks and luckily I fixed it at last. Please check the below files in ZTerm/msterm:
These files are from the code base of Windows Terminal. You can use some command like "diff" to compare what I modified so you can understand the key points to capture the text data in the current screen/terminal/pane.
I think if you understand the two points I said in the above, it is easy for you to create a AI service by yourslef.
Windows Terminal is the best!
Enjoy coding!
Regards,
Kevin
Beta Was this translation helpful? Give feedback.
All reactions