Documentation
¶
Overview ¶
Package app contains the root Bubble Tea model that owns every resource view and routes messages between them. It is the only place that wires concrete service implementations from k8s/resources into views via the port.Services bundle. View structs are value types and Update returns new values; the generic updateView helper exists because Go method sets cannot be expressed as a constraint.
Index ¶
- type ClusterInfo
- type Model
- func (m Model) Client() *k8sclient.Client
- func (m Model) CommandModeActive() bool
- func (m Model) FlashError() string
- func (m Model) Init() tea.Cmd
- func (m Model) Logs() port.LogService
- func (m Model) Metrics() port.MetricsService
- func (m Model) Namespace() string
- func (m Model) PaletteVisible() bool
- func (m Model) PodsFilter() string
- func (m Model) SetLogTailStarter(f func(ns string, pods []string, sinceSeconds int64))
- func (m Model) SetWatcherRestarter(f func(client *k8sclient.Client, ns string, metrics port.MetricsService, ...))
- func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m Model) View() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClusterInfo ¶ added in v0.3.0
type ClusterInfo struct {
Context string
Cluster string
User string
K8sVersion string
Region string
KlensVer string
}
ClusterInfo is the top-bar context block. Populated at New() time from the kubeconfig and discovery — values default to placeholders if unavailable so the bar still renders cleanly without a cluster.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the root Bubble Tea model. It owns all views, the input, the palette, and the cluster info shown in the top bar.
func New ¶
New builds the root model. Non-empty overrides take precedence over the config file: kubeconfigOverride replaces cfg.Kubeconfig, namespaceOverride replaces cfg.Namespace. Pass empty strings to fall back to the config. Tolerates a missing cluster: returns a Model with `client == nil` and the warning is logged to stderr — the runtime context picker takes over.
func (Model) CommandModeActive ¶ added in v0.3.0
CommandModeActive reports whether the inline `:` ex-mode prompt is active. Exposed so tests can verify the ctrl+p / `:` split without poking internals.
func (Model) FlashError ¶ added in v0.3.0
FlashError returns the current transient error banner text (empty when none). Set when an inline-ex command misses; cleared by flashClearMsg.
func (Model) Init ¶
Init implements tea.Model. It fires one UpdatedMsg per resource type so all view counts populate on first render, not just the focused view. No-ops when client is nil (context picker / offline boot).
func (Model) Logs ¶ added in v0.3.0
func (m Model) Logs() port.LogService
Logs returns the optional log service (may be nil if no cluster).
func (Model) Metrics ¶ added in v0.3.0
func (m Model) Metrics() port.MetricsService
Metrics returns the optional metrics service (may be nil).
func (Model) PaletteVisible ¶
PaletteVisible reports whether the modal command palette is open.
func (Model) PodsFilter ¶ added in v0.3.0
PodsFilter returns the per-view filter on the pods list. Used by tests to verify filter persistence across drill-downs.
func (Model) SetLogTailStarter ¶ added in v0.3.0
SetLogTailStarter wires the watcher's StartPodLogTails to the model so that `l` on a pod (or a range-shortcut on the logs view, or a workload-scoped drill-down) can begin a live log stream over one or more pods.
func (Model) SetWatcherRestarter ¶ added in v0.3.0
func (m Model) SetWatcherRestarter(f func(client *k8sclient.Client, ns string, metrics port.MetricsService, logs port.LogService))
SetWatcherRestarter wires a callback that stops the current watcher and starts a new one bound to the given client/namespace/services. main.go owns the watcher lifecycle, so the callback closes over its local pointer to the active *Watcher; the model invokes it from the runtime context-picker confirm path.
func (Model) Update ¶
Update implements tea.Model. It routes messages through the global key handler, the active sub-view, or the broadcast path (watcher events) and returns an updated Model plus any Cmds to run.
func (Model) View ¶
View composes the modern shell:
┌─────────────────────────────────────────────────────────────────┐ │ ctx maisa-sdlc · v1.30 · ▆ europa ── K L E N S ── ● live │ top bar ├─────────────────────────────────────────────────────────────────┤ │ ▌1 pods 4/23 2 deployments 14 3 services 12 ... │ nav strip │ filter chips ........................ │ chips │ │ │ table │ details │ content │ │ ├─────────────────────────────────────────────────────────────────┤ │ › / type to filter ↵ describe l logs / filter ? │ command bar └─────────────────────────────────────────────────────────────────┘
The vertical nav rail was replaced by a horizontal strip directly under the top bar — gives the table full horizontal real estate, drops the cluster- meta block (cpu/mem are unwired anyway), and consolidates the count onto the active nav item so it doesn't duplicate the resource label or scope.
The palette overlay replaces the entire frame when open; lipgloss has no real cell-coordinate overlay support, so this matches klens's pre-redesign behaviour.