AbanteAI/mentat

Textual improvements

PCSwingle opened this issue ยท 11 comments

As discussed here #502 (review):

  • x buttons in context pane to remove files.
  • A microphone emoji in the entry box to trigger /talk
  • The ability to change theme midsession with /config. The UX here is strange because presumably users will almost never switch back and forth. I wonder if there should be a sticky /config that saves it to the config or if some settings should be sticky and others not. (This is a bit weird because we have to determine which config file to save to. Maybe just always ~/.mentat/.mentat_config.json).

The UX here is strange because presumably users will almost never switch back and forth.

Just to chime in, I frequently change Emacs and CLI theme using pywal, like multiple times a day. It's a bit frustrating that the new Textual UI doesn't pick up the theme the rest of my CLI is using and I have burned my retinas twice already today :)

(Mildly related I would love to have a mentat --server so I could interface with mentat directly from Emacs, but that's beside the point)

@CarlQLange Thanks for the feedback.

You might already know this but as a quick fix you can change the theme by putting "theme": "dark" in your mentat config.

It seems in general like it's a hard problem to detect and match the user's terminal theme. It'd probably be good if we could at least serve dark mode if their bg color is darker than some threshold.

I like the idea of mentat --server. Maybe I'll make an issue for it. You imagine functionality similar to what e.g. nvim has: https://neovim.io/doc/user/remote.html

I don't know enough about Textual really, but I guess I'm surprised there isn't a way to just 'passthrough' to the terminal's set colours.

Anyway - very interesting link to nvim. I think that would fit the bill quite nicely - what I really want is to implement a frontend (or 'porcelain') for mentat in Emacs. It would potentially also be nice to be able to drive mentat from shell scripts. For example I might need to convert docker-compose files into kubernetes yaml in 50 repos. Mentat does quite a good job of this but I wish I could just write the instructions once and run it over each repo.

Following up on the colour theme stuff: I've had a peruse of the Textual documentation and it definitely doesn't seem like what I'm asking for will be easy and would require some work on Textual directly. Bit of a strange decision on Textual's part imho.

There is an issue though - some of the text colour is affected by my theme, so contrast is all over the place depending on my pywal theme.

textual-2024-02-14_17.27.50.mp4

@CarlQLange there is the python_client which you could use to build a front end. We should probably document it a bit better. I just use it for testing right now which you can see a few places in the codebase. Thanks for sharing the video. That is strange.

Following up on the colour theme stuff: I've had a peruse of the Textual documentation and it definitely doesn't seem like what I'm asking for will be easy and would require some work on Textual directly. Bit of a strange decision on Textual's part imho.

I agree; I was looking into it when I was trying to do exactly what you're asking for and I couldn't find any way to do it. Definitely annoying that textual doesn't have this built in.

There is an issue though - some of the text colour is affected by my theme, so contrast is all over the place depending on my pywal theme.

Unfortunately there's no way for us to do anything with user selected terminal colors.

Thanks for taking the time to submit your feedback! I definitely knew these would be issues coming in, although I still don't think there's any way to fix them, but I'll definitely still keep thinking about.

Other textual issues/improvements:

It seems like mentat uses quite a lot of CPU now - when it's streaming, it maxes out one of my cores. Related, it seems to stream characters a lot slower (and use more CPU) when there is a large chat - not even that large, two or three hundred lines will do it.

I can't select text from the chat anymore to copy-paste elsewhere, which is a workflow I didn't realise I had. (Shift key, thank you!)

@CarlQLange you probably can copy paste: https://textual.textualize.io/FAQ/

It seems like mentat uses quite a lot of CPU now - when it's streaming, it maxes out one of my cores. Related, it seems to stream characters a lot slower (and use more CPU) when there is a large chat - not even that large, two or three hundred lines will do it.

I'm actually working on fixing this; the reason this happens is because every time text is added I just add it to the main content widget and update it; of course, this is n^2 on the length of the content (because strings are immutable). Unfortunately, it's more complicated than just creating new widgets for every bit of text and adding them on. There should be a way to fix it though, and hopefully I can figure it out soon.

@PCSwingle Yeah, I took some time yesterday to see if I could use Textual's built-in RichLog widget instead, but it expects every write to be a line, and implementing a line buffer was too much hassle for me. I also don't know how it would impact the formatting.