Skip to content

Conversation

@jasonlife
Copy link

Previously, long queries in the CLI would scroll horizontally, causing the beginning of the text to disappear and making it difficult to review or edit long inputs.

This commit switches the underlying readline library from 'github.com/nyaosorg/go-readline-ny' to 'github.com/ergochat/readline'. The new library supports automatic line wrapping by default and handles prompt width calculations correctly, fixing issues with cursor positioning and arrow key navigation on wrapped lines.

Improvements:

  • Long queries now wrap to the next line instead of scrolling horizontally.
  • Navigation with arrow keys, Ctrl+A (start of line), and Ctrl+E (end of line) works correctly on wrapped lines.
  • Character deletion behaves as expected across multiple lines.

Key changes:

  • Replaced 'go-readline-ny' with 'ergochat/readline'.
  • Implemented 'TmuxAICompleter' in 'internal/chat_completer.go' to maintain tab completion functionality.
  • Updated 'internal/chat.go' to initialize and use the new readline configuration.

… library

Previously, long queries in the CLI would scroll horizontally, causing the beginning of the text to disappear and making it difficult to review or edit long inputs.

This commit switches the underlying readline library from 'github.com/nyaosorg/go-readline-ny' to 'github.com/ergochat/readline'. The new library supports automatic line wrapping by default and handles prompt width calculations correctly, fixing issues with cursor positioning and arrow key navigation on wrapped lines.

Improvements:
- Long queries now wrap to the next line instead of scrolling horizontally.
- Navigation with arrow keys, Ctrl+A (start of line), and Ctrl+E (end of line) works correctly on wrapped lines.
- Character deletion behaves as expected across multiple lines.

Key changes:
- Replaced 'go-readline-ny' with 'ergochat/readline'.
- Implemented 'TmuxAICompleter' in 'internal/chat_completer.go' to maintain tab completion functionality.
- Updated 'internal/chat.go' to initialize and use the new readline configuration.
@alvinunreal
Copy link
Owner

alvinunreal commented Dec 6, 2025

hi @jasonlife

I tested several readline libraries and readline-ny seemed to be the most bug-free.

I just tried your PR and pasting multiline content doesn't seem to work for me.
It executes line by line in this case.

@jasonlife
Copy link
Author

hi @jasonlife

I tested several readline libraries and readline-ny seemed to be the most bug-free.

I just tried your PR and pasting multiline content doesn't seem to work for me. It executes line by line in this case.

I see. I've never tried copy-pasting while working on it. I just tested it, and it only copied the first line, as you pointed out. Is writing the prompt in a separate text editor and copying it into the TmuxAI panel the best workflow and recommended method? I will experiment further to see if I can fix the multiline paste issue.

@alvinunreal
Copy link
Owner

Quick thing to add is ability to open current prompt in $EDITOR, like bash does when pressed ctrl+x ctrl+e

This would allow better multi line prompt writing.
Regarding the readline library, not sure if changing readling-ny makes sense, wasn't able to find any other mature library in go. Might be we find better ways to use readline-ny though.

This commit introduces a new '/paste' command to the CLI interface, addressing the limitation where pasting multiline text (e.g., code blocks) into the readline prompt would trigger immediate submission for each line.

Changes:
- Added 'pasteMode' state to CLIInterface to buffer input lines.
- Implemented '/paste' command to enter paste mode (prompt changes to '... ').
- Implemented '/end' command to submit the buffered content as a single message.
- Implemented '/cancel' command to exit paste mode without submitting.
- Updated help messages and command lists to include '/paste'.
@jasonlife
Copy link
Author

I have updated the branch with multiline paste capabilities via a new /paste command. I'm not sure if introducing a new command is the preferred solution here, but I believe it solves the issue effectively. Kindly review the update and let me know if this works for you.

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