Simatwa / python-tgpt

AI Chat in Terminal + Package + REST-API
https://python-tgpt.onrender.com
MIT License
102 stars 15 forks source link

[BUG]: In macOS, interactive mode prompt garbles if terminal less than 130 characters wide. #48

Closed StuDentered closed 4 months ago

StuDentered commented 4 months ago

Describe the bug in macOS, in terminals uxterm, iterm2, terminal, and many more, prompt of command "python3 -m pytgpt interactive" would garble if terminal if less than 130 characters wide.

To Reproduce Steps to reproduce the behavior:

  1. On macOS, Run "pip3 install python-tgpt" to install python-tgpt.
  2. Open another terminal window, 130 character or wider.
  3. Run "python3 -m pytgpt interactive"
  4. You would see proper prompt, it would look like:
  5. ╭─User@pyTGPT~[πŸ•’00:00:00-πŸ’»00:00:00-⚑0.0s] ╰─>
  6. Open another terminal window, (much) less than 130 characters.
  7. Run "python3 -m pytgpt interactive"
  8. You would see garbled prompt, looking like:
  9. "00:00:00-πŸ’»00:00:00-⚑0.0s]"
  10. ╰─>
  11. Note that part "00:00:00-πŸ’»00:00:00-⚑0.0s]" is exactly 31 chars long when echo'ed, and won't garble until terminal is less than 65 characters wide.

Expected behavior If terminal on macOS is less than 130 characters wide and "python3 -m pytgpt interactive" is run on it within "bash", prompt of that command would fold on itself instead of properly line breaking, as it is on other systems!

Screenshots or Code snippets If applicable, add screenshots or code snippets to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

Workaround It is caused by mishandled color codes by faulty-compiled Python version, and, maybe, something inside "pytgpt". Run "pytgpt" with "-nc" flag, and that issue would hide.

Simatwa commented 4 months ago

Could you please attach screenshot for that.