Documentation
¶
Overview ¶
Package tui is the single source of truth for the TUI handler-kind contract shared by github.com/tinywasm/devtui (the renderer/consumer) and github.com/tinywasm/app (the daemon producer).
A "handler" is any value a consumer registers with the TUI. The TUI inspects the handler's Go interface to decide how to render it (button, text field, radio group, log stream…) and, in client/daemon mode, how to serialize it over the wire (StateEntry). Historically each consumer re-derived that mapping independently, so adding or reordering a handler kind silently broke one side. This package centralizes the whole contract:
- Kind — the frozen enum (also the wire value).
- Classify/Extract — the ONE ordered interface-detection walk + metadata.
- StateEntry — the JSON wire format.
- AllKinds — lets every consumer write a guardrail test that fails loudly when a new Kind is not fully wired.
It has zero heavy dependencies (no charmbracelet/bubbletea/lipgloss), so the daemon can import it without pulling the terminal renderer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Kind ¶ added in v0.1.0
type Kind int
Kind identifies how a registered handler is rendered and serialized.
The integer values are the FROZEN wire protocol: they are written into StateEntry.HandlerType and read back by remote consumers. Never reorder or renumber existing kinds — only append new ones at the end. TestKindWireValues guards this.
const ( KindDisplay Kind = 0 // read-only footer text (Name + Content) KindEdit Kind = 1 // free-text input field (Name + Label + Value + Change) KindExecution Kind = 2 // action button (Name + Label + Execute) KindInteractive Kind = 3 // auto-editing field (Edit + WaitingForUser) KindLoggable Kind = 4 // log stream only, no footer field (Name + SetLog) KindSelection Kind = 5 // radio / segmented buttons (Edit + Options) )
func AllKinds ¶ added in v0.1.0
func AllKinds() []Kind
AllKinds returns every declared Kind in wire order. Consumers iterate this in their own guardrail tests to assert they handle every kind — so a newly appended Kind turns those tests red instead of degrading silently.
type Meta ¶ added in v0.1.0
type Meta struct {
Name string
Label string
Value string
Options []map[string]string
Shortcuts []map[string]string
}
Meta is the data Extract pulls off a handler. Fields are populated only when the handler exposes the corresponding method; the rest stay zero.
type StateEntry ¶ added in v0.1.0
type StateEntry struct {
TabTitle string `json:"tab_title"`
HandlerName string `json:"handler_name"`
HandlerColor string `json:"handler_color"`
HandlerType int `json:"handler_type"` // a Kind value
Label string `json:"label"`
Value string `json:"value"`
Shortcut string `json:"shortcut"` // primary key = handler Name()
Shortcuts []map[string]string `json:"shortcuts"` // from a Shortcuts() provider
Options []map[string]string `json:"options"` // Selection buttons: ordered {value:label}
}
StateEntry is the JSON wire format for a single handler registered in the daemon TUI. Produced by the daemon (github.com/tinywasm/app's HeadlessTUI), consumed by the client (github.com/tinywasm/devtui client mode).
The JSON tags are the published contract: any producer must match them exactly, and existing tags must never change. Only additive changes (new fields) are allowed.