tui

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 48 Imported by: 0

Documentation

Overview

Package tui implements kb's full-screen terminal interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(
	st *store.Store,
	databasePath, user, activeProject, version string,
	options ...tea.ProgramOption,
) (err error)

Run opens the data-version watcher and runs the full-screen program. activeProject is the project local commands default to, resolved by the caller that owns the data directory; it opens the switcher and defaults the editor's mandatory project field, and may be empty. version is the build identifier the launch screen's meta row prints (spec section 10.6.5); the TUI cannot reach package main's build info, so the caller passes it in and an empty string renders the meta row with its left slot only. Program options are accepted for deterministic tests; production passes none.

Types

type DataVersionWatcher

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

DataVersionWatcher compares PRAGMA data_version on one pinned SQLite connection. Values from pooled or replacement connections are unrelated and therefore useless for cross-process change detection.

func OpenDataVersionWatcher

func OpenDataVersionWatcher(ctx context.Context, path string) (*DataVersionWatcher, error)

OpenDataVersionWatcher opens a dedicated, otherwise-idle connection to the board database. It never holds a transaction across polls.

func (*DataVersionWatcher) Close

func (w *DataVersionWatcher) Close() error

Close releases the pinned connection and its one-connection pool.

func (*DataVersionWatcher) DataVersion

func (w *DataVersionWatcher) DataVersion(ctx context.Context) (int64, error)

DataVersion reads SQLite's connection-local external-change counter.

type Model

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

Model is the single Bubble Tea root. It owns board state, focus, terminal dimensions, and all message routing; commands perform IO and only return messages, so Update remains deterministic.

func NewModel

func NewModel(store boardReader, watcher dataVersionReader, user string) Model

NewModel creates the root model for one local board owner.

func (Model) Init

func (m Model) Init() tea.Cmd

Init loads the first board snapshot and starts the external-write watcher.

func (Model) RenderPlanStats

func (m Model) RenderPlanStats() RenderPlanStats

RenderPlanStats returns a value copy so instrumentation cannot mutate the frame or its revision graph.

func (*Model) SetActiveProject

func (m *Model) SetActiveProject(name string)

SetActiveProject hands the board the project local commands default to (KB_PROJECT, else the project stored by kb project use). It is the switcher's opening scope and the editor's default for a new card; stored preferences override the scope, never the default.

func (*Model) SetVersion

func (m *Model) SetVersion(version string)

SetVersion records the build version the launch screen's meta row prints. The TUI cannot reach package main's build info, so the string arrives on tui.Run and is stored here (spec section 10.6.5).

func (Model) Update

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

func (Model) View

func (r Model) View() tea.View

View returns the complete immutable frame most recently installed by Update. Rendering, hit-map construction, and overlay composition happen only at the render-plan publication seam.

type RenderPlanRevisions

type RenderPlanRevisions struct {
	Tasks      uint64 `json:"tasks"`
	Projection uint64 `json:"projection"`
	Layout     uint64 `json:"layout"`
	Appearance uint64 `json:"appearance"`
	Overlay    uint64 `json:"overlay"`
	Temporal   uint64 `json:"temporal"`
	Pointer    uint64 `json:"pointer"`
}

RenderPlanRevisions identifies the immutable inputs used to build the retained frame. Separate revisions keep layout invalidation independent from appearance invalidation instead of hiding both behind an unkeyed cache.

type RenderPlanStats

type RenderPlanStats struct {
	Revisions                      RenderPlanRevisions `json:"revisions"`
	AcceptedMessageID              uint64              `json:"accepted_message_id"`
	InstalledSnapshotID            uint64              `json:"installed_snapshot_id"`
	InstalledForMessageID          uint64              `json:"installed_for_message_id"`
	Builds                         uint64              `json:"builds"`
	PublishedFrames                uint64              `json:"published_frames"`
	DiscardedEvents                uint64              `json:"discarded_events"`
	PointerEventsAccepted          uint64              `json:"pointer_events_accepted"`
	PointerEventsDeferred          uint64              `json:"pointer_events_deferred"`
	PointerTrailingFlushes         uint64              `json:"pointer_trailing_flushes"`
	PointerIntentPending           bool                `json:"pointer_intent_pending"`
	StaleWorkerResults             uint64              `json:"stale_worker_results"`
	StaleGeometryRootResults       uint64              `json:"stale_geometry_root_results"`
	ProjectionBuilds               uint64              `json:"projection_builds"`
	ProjectionTaskVisits           uint64              `json:"projection_task_visits"`
	SourceTaskComparisons          uint64              `json:"source_task_comparisons"`
	TaskDerivations                uint64              `json:"task_derivations"`
	TaskDerivationBuilds           uint64              `json:"task_derivation_builds"`
	ProjectedTasks                 uint64              `json:"projected_tasks"`
	LayoutRecords                  uint64              `json:"layout_records"`
	ExactLayoutRecords             uint64              `json:"exact_layout_records"`
	EstimatedLayoutRecords         uint64              `json:"estimated_layout_records"`
	GeometryWorkerSlices           uint64              `json:"geometry_worker_slices"`
	MaxGeometryWorkerSliceNS       int64               `json:"max_geometry_worker_slice_ns"`
	GeometryWorkerOverruns         uint64              `json:"geometry_worker_overruns"`
	GeometryCacheHits              uint64              `json:"geometry_cache_hits"`
	GeometryCacheMisses            uint64              `json:"geometry_cache_misses"`
	GeometryCacheEvictions         uint64              `json:"geometry_cache_evictions"`
	GeometryCacheInvalidations     uint64              `json:"geometry_cache_invalidations"`
	GeometryCacheEntries           uint64              `json:"geometry_cache_entries"`
	GeometryCacheOwnedBytes        uint64              `json:"geometry_cache_owned_bytes"`
	RenderedCardRecords            uint64              `json:"rendered_card_records"`
	NavigationArtifactHits         uint64              `json:"navigation_artifact_hits"`
	NavigationArtifactMisses       uint64              `json:"navigation_artifact_misses"`
	NavigationArtifactPublications uint64              `json:"navigation_artifact_publications"`
	NavigationArtifactFallbacks    uint64              `json:"navigation_artifact_fallbacks"`
	WatcherPollFastPaths           uint64              `json:"watcher_poll_fast_paths"`
	WatcherVersionFastPaths        uint64              `json:"watcher_version_fast_paths"`
	WatcherStaleLoadFastPaths      uint64              `json:"watcher_stale_load_fast_paths"`
	WatcherLifecycleFallbacks      uint64              `json:"watcher_lifecycle_fallbacks"`
	RenderImpactClassifications    uint64              `json:"render_impact_classifications"`
	SynchronousLayoutRecords       uint64              `json:"synchronous_layout_records"`
	SynchronousIndexNodes          uint64              `json:"synchronous_index_nodes"`
	GeometrySnapshotInstalls       uint64              `json:"geometry_snapshot_installs"`
	MaxGeometryInstallUnits        uint64              `json:"max_geometry_install_units"`
	ContentBytes                   uint64              `json:"content_bytes"`
	HitRegions                     uint64              `json:"hit_regions"`
	RetainedPlanOwnedBytesEstimate uint64              `json:"retained_plan_owned_bytes_estimate"`
	NormalBaseBuilds               uint64              `json:"normal_base_builds"`
	DimmedBaseBuilds               uint64              `json:"dimmed_base_builds"`
	OverlayCompositions            uint64              `json:"overlay_compositions"`
	TemporalScheduledTicks         uint64              `json:"temporal_scheduled_ticks"`
	TemporalStaleTicks             uint64              `json:"temporal_stale_ticks"`
	TemporalTaskVisits             uint64              `json:"temporal_task_visits"`
	TemporalRecordsRefreshed       uint64              `json:"temporal_records_refreshed"`
	TemporalIndexNodesVisited      uint64              `json:"temporal_index_nodes_visited"`
	ShippedIDVisits                uint64              `json:"shipped_id_visits"`
}

RenderPlanStats is the instrumentation seam used by the regression harness. DiscardedEvents and StaleWorkerResults are zero until their bounded-admission and worker slices land; reserving them here keeps one report contract.

Directories

Path Synopsis
Package action owns kb's keyboard action registry: one table naming every action the board offers, the key that drives it, and the words that describe it.
Package action owns kb's keyboard action registry: one table naming every action the board offers, the key that drives it, and the words that describe it.
Package adrsplit implements the direct-runner ADR-to-stories review overlay.
Package adrsplit implements the direct-runner ADR-to-stories review overlay.
Package carddetail renders the full-card overlay and its direct-store comment and blocker-link actions.
Package carddetail renders the full-card overlay and its direct-store comment and blocker-link actions.
Package cardeditor implements the direct-store create and edit overlay.
Package cardeditor implements the direct-store create and edit overlay.
Package cmdpalette renders kb's ctrl+k command palette: a fuzzy search over the action registry, elevated as the overlay of spec section 4.
Package cmdpalette renders kb's ctrl+k command palette: a fuzzy search over the action registry, elevated as the overlay of spec section 4.
Package formview renders terminal form controls shared by TUI overlays.
Package formview renders terminal form controls shared by TUI overlays.
Package issueimport implements the direct-store forge import review overlay.
Package issueimport implements the direct-store forge import review overlay.
Package mdparity is the one grammar kb reduces a card description to before anything renders it.
Package mdparity is the one grammar kb reduces a card description to before anything renders it.
Package pointer maps rendered terminal cells to pointer interactions.
Package pointer maps rendered terminal cells to pointer interactions.
Package theme owns kb's TUI design tokens: the semantic palette of docs/design/tui-design-spec.md section 1, the cached style factory of section 6, and the layout metrics and glyphs of section 2.
Package theme owns kb's TUI design tokens: the semantic palette of docs/design/tui-design-spec.md section 1, the cached style factory of section 6, and the layout metrics and glyphs of section 2.
Package widget holds kb's hand-crafted TUI elements: the last resort of the charm-first sourcing rule of map #136, allowed only for the elements charm does not ship.
Package widget holds kb's hand-crafted TUI elements: the last resort of the charm-first sourcing rule of map #136, allowed only for the elements charm does not ship.
spin
Package spin is the branded spinner engine of spec section 10.2.5: the gradient label that wipes in column by column while kb waits on a network round trip or a model inference.
Package spin is the branded spinner engine of spec section 10.2.5: the gradient label that wipes in column by column while kb waits on a network round trip or a model inference.

Jump to

Keyboard shortcuts

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