timeline

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 10 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterUIForwarder added in v0.0.29

func RegisterUIForwarder(bus *eventbus.Bus, p *tea.Program)

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

func (c *Controller) GetLastLLMByRole(role string) (EntityID, map[string]any, bool)

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 EntityCompletedMsg struct {
	ID     EntityID
	Result map[string]any
}

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

type EntityModel interface{ tea.Model }

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 EntityPropsUpdatedMsg struct {
	ID    EntityID
	Patch map[string]any
}

type EntitySelectedMsg

type EntitySelectedMsg struct{ ID EntityID }

Messages sent to interactive EntityModels via their Update method

type EntitySetSizeMsg

type EntitySetSizeMsg struct{ Width, Height int }

Size and focus messages

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

type RendererDescriptor struct {
	Key  string `json:"key"`
	Kind string `json:"kind"`
}

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

func NewShell(reg *Registry) *Shell

NewShell constructs a Shell with a fresh Controller backed by the provided registry.

func (*Shell) AtBottom

func (s *Shell) AtBottom() bool

AtBottom returns whether the viewport is currently at the bottom.

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

func (s *Shell) GetLastLLMByRole(role string) (EntityID, map[string]any, bool)

Helpers for querying last assistant response

func (*Shell) GotoBottom

func (s *Shell) GotoBottom()

GotoBottom forces the viewport to scroll to the bottom.

func (*Shell) HandleMsg

func (s *Shell) HandleMsg(msg tea.Msg) tea.Cmd

func (*Shell) Init

func (s *Shell) Init() tea.Cmd

Init initializes the underlying viewport.

func (*Shell) IsEntering

func (s *Shell) IsEntering() bool

func (*Shell) OnCompleted

func (s *Shell) OnCompleted(e UIEntityCompleted)

func (*Shell) OnCreated

func (s *Shell) OnCreated(e UIEntityCreated)

Lifecycle wrappers

func (*Shell) OnDeleted

func (s *Shell) OnDeleted(e UIEntityDeleted)

func (*Shell) OnUpdated

func (s *Shell) OnUpdated(e UIEntityUpdated)

func (*Shell) RefreshView

func (s *Shell) RefreshView(goToBottom bool)

RefreshView regenerates the viewport content and optionally scrolls to bottom.

func (*Shell) ScrollDown

func (s *Shell) ScrollDown(n int)

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) ScrollUp

func (s *Shell) ScrollUp(n int)

ScrollUp scrolls the viewport by n lines.

func (*Shell) SelectLast

func (s *Shell) SelectLast()

Selection helpers and routing

func (*Shell) SelectNext

func (s *Shell) SelectNext()

func (*Shell) SelectPrev

func (s *Shell) SelectPrev()

func (*Shell) SelectedIndex

func (s *Shell) SelectedIndex() int

func (*Shell) SendToSelected

func (s *Shell) SendToSelected(msg tea.Msg) tea.Cmd

func (*Shell) SetScrollToBottom

func (s *Shell) SetScrollToBottom(v bool)

SetScrollToBottom toggles auto scroll-to-bottom behavior on refreshes.

func (*Shell) SetSelectionVisible

func (s *Shell) SetSelectionVisible(v bool)

func (*Shell) SetSize

func (s *Shell) SetSize(width, height int)

SetSize sets shell dimensions and forwards sizes to the controller.

func (*Shell) Unselect

func (s *Shell) Unselect()

func (*Shell) UpdateViewport

func (s *Shell) UpdateViewport(msg tea.Msg) tea.Cmd

UpdateViewport forwards messages to the viewport (e.g., scrolling) and returns any command.

func (*Shell) View

func (s *Shell) View() string

View returns the current timeline view as rendered within the viewport.

func (*Shell) ViewAndSelectedPosition

func (s *Shell) ViewAndSelectedPosition() (string, int, int)

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.

type UIEntityUpdated

type UIEntityUpdated struct {
	ID        EntityID       `json:"id"`
	Patch     map[string]any `json:"patch"`
	Version   int64          `json:"version"`
	UpdatedAt time.Time      `json:"updated_at"`
}

UIEntityUpdated streams updates to an existing entity.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL