Documentation
¶
Index ¶
- func RegisterUIForwarder(bus *eventbus.Bus, p *tea.Program)
- func VersionNow() int64
- type Controller
- func (c *Controller) EnterSelection()
- func (c *Controller) ExitSelection()
- func (c *Controller) GetLastLLMByRole(role string) (EntityID, map[string]any, bool)
- func (c *Controller) GetSelectedMeta() (EntityID, RendererDescriptor, map[string]any, bool)
- func (c *Controller) HandleMsg(msg tea.Msg) tea.Cmd
- func (c *Controller) IsEntering() bool
- func (c *Controller) OnCompleted(e UIEntityCompleted)
- func (c *Controller) OnCreated(e UIEntityCreated)
- func (c *Controller) OnDeleted(e UIEntityDeleted)
- func (c *Controller) OnUpdated(e UIEntityUpdated)
- func (c *Controller) SelectLast()
- func (c *Controller) SelectNext()
- func (c *Controller) SelectPrev()
- func (c *Controller) SelectedIndex() int
- func (c *Controller) SendToSelected(msg tea.Msg) tea.Cmd
- func (c *Controller) SetSelectionVisible(v bool)
- func (c *Controller) SetSize(w, h int)
- func (c *Controller) SetTheme(theme string)
- func (c *Controller) Unselect()
- func (c *Controller) UpdateSelected(patch map[string]any) bool
- func (c *Controller) View() string
- func (c *Controller) ViewAndSelectedPosition() (string, int, int)
- type CopyCodeRequestedMsg
- type CopyTextRequestedMsg
- type EntityBlurMsg
- type EntityCompletedMsg
- type EntityCopyCodeMsg
- type EntityCopyTextMsg
- type EntityCreatedMsg
- type EntityFocusMsg
- type EntityID
- type EntityModel
- type EntityModelFactory
- type EntityPropsUpdatedMsg
- type EntitySelectedMsg
- type EntitySetSizeMsg
- type EntityUnselectedMsg
- type Registry
- type RendererDescriptor
- type Shell
- func (s *Shell) AtBottom() bool
- func (s *Shell) Controller() *Controller
- func (s *Shell) EnterSelection()
- func (s *Shell) ExitSelection()
- func (s *Shell) GetLastLLMByRole(role string) (EntityID, map[string]any, bool)
- func (s *Shell) GotoBottom()
- func (s *Shell) HandleMsg(msg tea.Msg) tea.Cmd
- func (s *Shell) Init() tea.Cmd
- func (s *Shell) IsEntering() bool
- func (s *Shell) OnCompleted(e UIEntityCompleted)
- func (s *Shell) OnCreated(e UIEntityCreated)
- func (s *Shell) OnDeleted(e UIEntityDeleted)
- func (s *Shell) OnUpdated(e UIEntityUpdated)
- func (s *Shell) RefreshView(goToBottom bool)
- func (s *Shell) ScrollDown(n int)
- func (s *Shell) ScrollToSelected()
- func (s *Shell) ScrollUp(n int)
- func (s *Shell) SelectLast()
- func (s *Shell) SelectNext()
- func (s *Shell) SelectPrev()
- func (s *Shell) SelectedIndex() int
- func (s *Shell) SendToSelected(msg tea.Msg) tea.Cmd
- func (s *Shell) SetScrollToBottom(v bool)
- func (s *Shell) SetSelectionVisible(v bool)
- func (s *Shell) SetSize(width, height int)
- func (s *Shell) Unselect()
- func (s *Shell) UpdateViewport(msg tea.Msg) tea.Cmd
- func (s *Shell) View() string
- func (s *Shell) ViewAndSelectedPosition() (string, int, int)
- type UIEntityCompleted
- type UIEntityCreated
- type UIEntityDeleted
- type UIEntityUpdated
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterUIForwarder ¶ added in v0.0.29
RegisterUIForwarder adds a handler that forwards ui.entities to a tea.Program as Bubble Tea messages.
func VersionNow ¶
func VersionNow() int64
Version helpers if callers need monotonically increasing versions; callers can pass time.Now().UnixNano()
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
func NewController ¶
func NewController(reg *Registry) *Controller
func (*Controller) EnterSelection ¶
func (c *Controller) EnterSelection()
EnterSelection toggles entering mode; when true, key events should go to selected entity
func (*Controller) ExitSelection ¶
func (c *Controller) ExitSelection()
func (*Controller) GetLastLLMByRole ¶
GetLastLLMByRole returns the most recent llm_text entity matching the role if present.
func (*Controller) GetSelectedMeta ¶
func (c *Controller) GetSelectedMeta() (EntityID, RendererDescriptor, map[string]any, bool)
GetSelectedMeta returns ID, renderer and props of the selected entity
func (*Controller) HandleMsg ¶
func (c *Controller) HandleMsg(msg tea.Msg) tea.Cmd
HandleMsg routes a Bubble Tea message to the selected entity model. Normally, routing only occurs when entering is true. However, TAB and shift+TAB are allowed to pass through even when not entering so selected entities can implement compact toggles without full focus transfer.
func (*Controller) IsEntering ¶
func (c *Controller) IsEntering() bool
func (*Controller) OnCompleted ¶
func (c *Controller) OnCompleted(e UIEntityCompleted)
func (*Controller) OnCreated ¶
func (c *Controller) OnCreated(e UIEntityCreated)
func (*Controller) OnDeleted ¶
func (c *Controller) OnDeleted(e UIEntityDeleted)
func (*Controller) OnUpdated ¶
func (c *Controller) OnUpdated(e UIEntityUpdated)
func (*Controller) SelectLast ¶
func (c *Controller) SelectLast()
SelectLast selects the last entity if any exist.
func (*Controller) SelectNext ¶
func (c *Controller) SelectNext()
func (*Controller) SelectPrev ¶
func (c *Controller) SelectPrev()
func (*Controller) SelectedIndex ¶
func (c *Controller) SelectedIndex() int
SelectedIndex returns the current selected index or -1 if none.
func (*Controller) SendToSelected ¶
func (c *Controller) SendToSelected(msg tea.Msg) tea.Cmd
SendToSelected sends a message to the currently selected entity model regardless of entering state.
func (*Controller) SetSelectionVisible ¶
func (c *Controller) SetSelectionVisible(v bool)
SetSelectionVisible toggles whether renderers should highlight selection.
func (*Controller) SetSize ¶
func (c *Controller) SetSize(w, h int)
func (*Controller) SetTheme ¶
func (c *Controller) SetTheme(theme string)
func (*Controller) Unselect ¶
func (c *Controller) Unselect()
Unselect clears the current selection index
func (*Controller) UpdateSelected ¶
func (c *Controller) UpdateSelected(patch map[string]any) bool
UpdateSelected applies a patch to the selected entity props and invalidates cache
func (*Controller) View ¶
func (c *Controller) View() string
func (*Controller) ViewAndSelectedPosition ¶
func (c *Controller) ViewAndSelectedPosition() (string, int, int)
ViewAndSelectedPosition returns the full rendered view and the offset/height of the selected entity
type CopyCodeRequestedMsg ¶
type CopyCodeRequestedMsg struct{ Code string }
type CopyTextRequestedMsg ¶
type CopyTextRequestedMsg struct{ Text string }
Messages emitted by models for side-effects handled by parent
type EntityBlurMsg ¶
type EntityBlurMsg struct{ ID EntityID }
type EntityCompletedMsg ¶
type EntityCopyCodeMsg ¶
type EntityCopyCodeMsg struct{ ID EntityID }
type EntityCopyTextMsg ¶
type EntityCopyTextMsg struct{ ID EntityID }
Actions that parent can request from models
type EntityCreatedMsg ¶
type EntityCreatedMsg struct {
ID EntityID
Renderer RendererDescriptor
Props map[string]any
StartedAt time.Time
}
Entity lifecycle messages as Bubble Tea messages (optional alternative to direct calls)
type EntityFocusMsg ¶
type EntityFocusMsg struct{ ID EntityID }
type EntityID ¶
type EntityID struct {
RunID string `json:"run_id,omitempty"`
TurnID string `json:"turn_id,omitempty"`
BlockID string `json:"block_id,omitempty"`
LocalID string `json:"local_id,omitempty"`
Kind string `json:"kind"`
}
EntityID identifies a UI entity in the timeline.
type EntityModel ¶
EntityModel represents an interactive per-entity UI model It renders itself and can handle messages routed by the controller. For simplicity, View takes selection/focus flags.
type EntityModelFactory ¶
type EntityModelFactory interface {
Key() string
Kind() string
NewEntityModel(initialProps map[string]any) EntityModel
}
EntityModelFactory constructs an EntityModel for a given renderer Key/Kind
type EntityPropsUpdatedMsg ¶
type EntitySelectedMsg ¶
type EntitySelectedMsg struct{ ID EntityID }
Messages sent to interactive EntityModels via their Update method
type EntityUnselectedMsg ¶
type EntityUnselectedMsg struct{ ID EntityID }
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) GetModelFactoryByKey ¶
func (r *Registry) GetModelFactoryByKey(key string) (EntityModelFactory, bool)
func (*Registry) GetModelFactoryByKind ¶
func (r *Registry) GetModelFactoryByKind(kind string) (EntityModelFactory, bool)
func (*Registry) RegisterModelFactory ¶
func (r *Registry) RegisterModelFactory(factory EntityModelFactory)
type RendererDescriptor ¶
RendererDescriptor selects a renderer implementation on the UI side.
type Shell ¶
type Shell struct {
// contains filtered or unexported fields
}
Shell wraps a Controller with viewport management and selection helpers so it can be embedded as a reusable timeline UI component.
func NewShell ¶
NewShell constructs a Shell with a fresh Controller backed by the provided registry.
func (*Shell) Controller ¶
func (s *Shell) Controller() *Controller
Controller returns the underlying timeline controller.
func (*Shell) EnterSelection ¶
func (s *Shell) EnterSelection()
func (*Shell) ExitSelection ¶
func (s *Shell) ExitSelection()
func (*Shell) GetLastLLMByRole ¶
Helpers for querying last assistant response
func (*Shell) GotoBottom ¶
func (s *Shell) GotoBottom()
GotoBottom forces the viewport to scroll to the bottom.
func (*Shell) IsEntering ¶
func (*Shell) OnCompleted ¶
func (s *Shell) OnCompleted(e UIEntityCompleted)
func (*Shell) OnDeleted ¶
func (s *Shell) OnDeleted(e UIEntityDeleted)
func (*Shell) OnUpdated ¶
func (s *Shell) OnUpdated(e UIEntityUpdated)
func (*Shell) RefreshView ¶
RefreshView regenerates the viewport content and optionally scrolls to bottom.
func (*Shell) ScrollDown ¶
ScrollDown scrolls the viewport by n lines.
func (*Shell) ScrollToSelected ¶
func (s *Shell) ScrollToSelected()
ScrollToSelected mirrors the computation used in Chat model to keep selection in view.
func (*Shell) SelectNext ¶
func (s *Shell) SelectNext()
func (*Shell) SelectPrev ¶
func (s *Shell) SelectPrev()
func (*Shell) SelectedIndex ¶
func (*Shell) SetScrollToBottom ¶
SetScrollToBottom toggles auto scroll-to-bottom behavior on refreshes.
func (*Shell) SetSelectionVisible ¶
func (*Shell) UpdateViewport ¶
UpdateViewport forwards messages to the viewport (e.g., scrolling) and returns any command.
type UIEntityCompleted ¶
type UIEntityCompleted struct {
ID EntityID `json:"id"`
Result map[string]any `json:"result,omitempty"`
}
UIEntityCompleted finalizes the entity state.
type UIEntityCreated ¶
type UIEntityCreated struct {
ID EntityID `json:"id"`
Renderer RendererDescriptor `json:"renderer"`
Props map[string]any `json:"props"`
StartedAt time.Time `json:"started_at"`
Labels map[string]string `json:"labels,omitempty"`
}
UIEntityCreated is emitted when an entity is created/started.
type UIEntityDeleted ¶
type UIEntityDeleted struct {
ID EntityID `json:"id"`
}
UIEntityDeleted removes an entity from the timeline.