amfora
amfora copied to clipboard
Rewrite to use Charm ecosystem
This is just an idea, and not something coming anytime soon, if at all.
The current UI framework, cview, would be replaced by Bubble Tea and other projects from @charmbracelet.
Doing this would qualify for increasing Amfora's major version number (Amfora 2), as it would be a complete visual redesign and would break themes and probably some other UI config options.
For
- Bubble Tea uses The Elm Architecture pattern, as opposed to cview's callback structure
- I haven't used it yet, but the Elm architecture looks preferable: simpler, easier to write
- And most importantly, I think it would reduce bugs caused by different callbacks interfering with each other (#281 #283 among others), as the whole program would act like a single-threaded state machine
- There would still be multi-threaded code for things like network requests, but it would have to check back in to the single-threaded renderer before it could display anything, which should prevent most (all?) async render issues
- Would clean up and simplify code that deals with re-rendering everything, like for resizing. So it would solve #276
- All current rendering issues would be gone, as they were caused by cview bugs
- Maybe #183 wouldn't be solved, needs testing but ultimately it doesn't matter
- It's possible I could fix these issues in cview myself, but when I've looked into the code in the past I had a hard time understanding it, let alone debugging it
- Probably conforms to semver better than cview, allowing for easier upgrades
- UI components would mostly be made by hand, allowing for more control and less fighting with cview
- Would require less hacking to do something like #197, which was a lot of hacking and work to do, and is still an annoying section to come back to and maintain if needed
- Other code for tabs like "saving" and "applying" the bottombar works fine now but is hacky and would be avoided by this
Against
- The rendering issues might get solved by the cview dev in the future
- It would be a lot of work, basically a complete rewrite of all the UI code (code in
display/) which is the bulk of Amfora - And arguably for small gain. While the problems it would solve (listed above) are annoying, they don't really matter for most usage, and things work well overall
- Possibly less stable API than cview since still in v0
- UI components would be more work to write initially, as there aren't premade ones like modals etc
- UI keyboard focus flow would likely require significant extra code, because that isn't handled by Bubble Tea
- So keeping track of what's in focus, and then moving focus when modals are exited, tab key is pressed, etc, would all need to be written
Honestly, a major part of why I've written this up is because the @charmbracelet stuff seems super cool and I feel like I need to use it. I will write something smaller using it from scratch, as a way to try it out, and maybe to get it out of my system :wink:. For now this will just remain another far off idea I wanted to record just in case.