tui

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 47 Imported by: 0

Documentation

Overview

Package tui is kith's presentation layer: a Bubble Tea program that talks to the world only through api.Backend. The frame is a spaces rail, the room list for the selected rail group, and the timeline with its composer.

Index

Constants

This section is empty.

Variables

View Source
var ErrOpenedElsewhere = errors.New("kith was opened in another window")

ErrOpenedElsewhere is Run ending because another window took the seat.

Functions

func EmojiCells

func EmojiCells(display config.Display) ([]string, error)

EmojiCells is every cell the browser would draw for a display configuration, toned and presentation-reconciled. Exported for cmd/emoji-probe, which asks the terminal how wide each really is.

func Run

func Run(ctx context.Context, opts RunOptions) error

Run starts the Bubble Tea program bound to ctx and blocks until it exits.

Types

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is the root Bubble Tea model driving the three-pane frame.

func New

func New(ctx context.Context, backend api.Backend, display config.Display) Model

New returns a Model wired to backend, using ctx for all backend calls.

func (Model) Init

func (m Model) Init() tea.Cmd

Init renders from the cache, starts background refreshes and the sync streams.

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update routes a message to its handler, then runs the steps every state change needs (jumplist, derived cache, arming timers, quotes, inline pictures) once here rather than at each call site.

func (Model) View

func (m Model) View() tea.View

View renders the three-pane frame with a status line beneath it. It writes nothing shared. For the Model Update returned, the shared cache is final (primeTimeline, and TestViewLeavesTheSharedCacheAlone), so View only reads it; any other Model (an older copy, one built by hand) is laid out on a private scratch cache.

func (Model) WithCache

func (m Model) WithCache(cache *media.Cache) Model

func (Model) WithConfigFile

func (m Model) WithConfigFile(path string, cfg config.Config) Model

WithConfigFile sets where settings are written back and applies the config's integrations. Without a path, changes apply but are not saved.

func (Model) WithFollow

func (m Model) WithFollow(uri string) Model

WithFollow gives the model a link to follow as soon as it knows where it is.

func (Model) WithKeys

func (m Model) WithKeys(keys config.Keys) Model

WithKeys replaces the keymap with one built from config; config issues are reported on the status line and in help, never fatal.

func (Model) WithLogger

func (m Model) WithLogger(log *slog.Logger) Model

WithCache gives the model a picture cache; without one it re-renders each time. WithLogger sets where failures are logged; the status line shows them briefly, the log keeps them. nil keeps the silent default.

func (Model) WithNotifications

func (m Model) WithNotifications(n Notifications) Model

WithNotifications wires in the daemon's notification controls (do-not-disturb, config reload).

func (Model) WithRules

func (m Model) WithRules(rules []notify.Rule, me string, on bool) Model

WithRules sets the notification rules to describe (the badge) and our MXID. Delivery is the daemon's.

func (Model) WithSchedules

func (m Model) WithSchedules(s Schedules) Model

WithSchedules wires in the send-later queue.

type Notifications

type Notifications interface {
	// SetDND puts one temporary rule in force. Every method returns the whole set
	// afterwards.
	SetDND(ctx context.Context, rule notify.Rule) (notify.Temps, error)
	// ClearDND lifts the rule naming this place and person, ClearAllDND every one.
	ClearDND(ctx context.Context, match, sender string) (notify.Temps, error)
	ClearAllDND(ctx context.Context) (notify.Temps, error)
	// DND reports the temporary rules in force.
	DND(ctx context.Context) (notify.Temps, error)
	// ReloadConfig asks the daemon to re-read the configuration file, returning the
	// parse error when it will not load.
	ReloadConfig(ctx context.Context) error
}

Notifications is the daemon's notification state, as much as the client acts on. Declared here because only daemon.Remote implements it.

type RunOptions

type RunOptions struct {
	Backend api.Backend
	// Notifications and Schedules are daemon-only services, not api.Backend roles.
	Notifications Notifications
	Schedules     Schedules
	Config        config.Config
	// ConfigPath is where in-app setting changes are written.
	ConfigPath string
	// Me is the logged-in MXID.
	Me string
	// Log is the client's log (a file: the terminal is the program's).
	Log *slog.Logger
	// Follow is a matrix URI to open at start, or "".
	Follow string
}

RunOptions is what the program runs with.

type Schedules

type Schedules interface {
	// Schedule queues a message, returning the handle that cancels it.
	Schedule(ctx context.Context, msg domain.ScheduledMessage) (string, error)
	// ScheduledMessages is the whole queue, every room, soonest first.
	ScheduledMessages(ctx context.Context) ([]domain.ScheduledMessage, error)
	// CancelScheduled drops one pending message.
	CancelScheduled(ctx context.Context, id string) error
}

Schedules queues messages written now and sent later. Declared here rather than in internal/api because only the daemon (daemon.Remote) can implement it: a message sent only while the client is open is not scheduled, just late.

Jump to

Keyboard shortcuts

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