prompt-toolkit / prompt-toolkit/python-prompt-toolkit
prevent HSplit/VSplit from growing children to fill all available space
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
I'm having issues trying to create a really simple chat program for an LLM (large language model), RWKV. I've used just basic input() for my last script, but things that have been written to the terminal can't be modified then, so I can't provide a good user experience for undo and regen and editing and etc. I thought a TUI library might help with this, and I remembered that prompt_toolkit seems to support creating really rich experiences (I remember ptpython very fondly), but I'm already just about ready to give up ...
for example if I just want to display a list of messages to the terminal, I can use a non-fullscreen application and an HSplit containing the list of messages, and at first it appears to work properly:
-
The messages only take up the space that is required
-
The space grows to fill if you put newlines in a message
but there is an issue:
-
if you remove a line, empty spaces start to appear what?
-
if you expand the space all the way, oops it looks like the items are being evenly spaced out
oops it looks like there is no way to disable this behavior and it's completely intended.
-
but wait, if you exit the app, the thing reformats itself to take up the minimum space (which proves it's possible and supported by the code)
there are branches in the source code dedicated to doing this (forcing the layout to never shrink its height), until the app exits. only then is it shrunk, as it should have been while it was running (because then app.is_done is true, and the layout uses THAT as its signal to shrink).
do I need to create a custom subclass in order to represent multiple messages in a simple chat log ? there seems to be no way to prevent prompt_toolkit from growing the items like this, but I don't want that, I want the layout to shrink again if the minimum size decreases. :/
kind of frustrated because it seems like this library is perfectly capable of doing what I want, and even does it in certain situations, but doesn't let me configure it and seems to be explicitly designed to do the opposite by force
this seems like a really really basic thing - is there no basic stack layout? only linear row/column layouts? :/
(I could not find any suitable issue about this specifically, searching for things like grow, flex, hsplit, vsplit, layout, stack, list, chat etc.)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how HSplit and VSplit size their children, especially the layout behavior that changes when app.is_done is true. Reproduce the message-list example while removing lines and expanding the available space, then determine what behavior is expected when the minimum size decreases. Done means children no longer retain or evenly share unnecessary space during a running application.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100