Replies: 2 comments
-
|
I love it. I think it could be possible to extend this as some other agents do to expose a GRPC API so that one can more easily extend the tool (not that this is directly related to this proposal, but it's in the same idea). |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
This is a great, and very much needed, idea. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Context:
Currently, in
internal/tui, we observe thattea.Models defined withininternal/tui/page/andinternal/tui/components/are handlingtea.Msgs originating from other distinct components or global application events. For example,internal/tui/page/chat/chat.godirectly handles messages fromeditor,splash,commands,filepicker,completions, and variouspubsub.Eventtypes. Similarly,internal/tui/components/chat/chat.gohandles globalpubsub.Events andSessionSelectedMsgfrom outside its immediate scope.Problem:
This current approach, while functional, leads to a tightly coupled message flow within the TUI. As the application grows and more components are introduced, the
Updatemethods of parent models become increasingly complex, acting as central dispatchers for a multitude of messages from various sources. This can result in:Updatemethod of a single model becomes responsible for understanding and reacting to messages from many different parts of the application, making it harder to read, understand, and maintain.Updatemethods.Proposal:
To address these issues and promote a more scalable and maintainable TUI architecture, I propose the following changes to our
tea.Msghandling strategy:Introduce a
internal/tui/events/Directory:tea.Msgtypes that are intended to be global or are shared between multiple, otherwise unrelated, components.pubsub.Eventwrappers, general application events (e.g.,InfoMsg,ErrorMsg), or messages indicating that an event has occurred (e.g.,SessionSelected,CompactModeToggled).Encapsulate Component-Specific Messages:
tea.Msgtypes that are strictly internal to a component's functionality and are only consumed by that component'sUpdatemethod (or its direct parent, if the parent's role is specifically to manage that child) should be defined asprivatetypes within that component's package.editor.OpenEditorMsg,chat.SendMsg,splash.SubmitAPIKeyMsg, etc., would remain within their respective component packages but would be unexported (lowercase first letter).Benefits:
UpdateMethods: Parent models will have a clearer understanding of which messages they truly need to handle, focusing on orchestrating their direct children or responding to global events.internal/tui/events/and understand component-specific interactions by examining the component's own package.tea.Msgtypes ininternal/tui/events/will serve as a well-defined API for inter-component communication.Example of Changes (Conceptual):
I believe this refactoring will significantly improve the architectural clarity and long-term maintainability of our TUI.
Looking forward to your thoughts and feedback!
Beta Was this translation helpful? Give feedback.
All reactions