app

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 16 Imported by: 0

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

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

func New(kubeconfigOverride, namespaceOverride string) (Model, error)

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

func (m Model) Client() *k8sclient.Client

Client returns the underlying k8s client (may be nil if no cluster).

func (Model) CommandModeActive added in v0.3.0

func (m Model) CommandModeActive() bool

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

func (m Model) FlashError() string

FlashError returns the current transient error banner text (empty when none). Set when an inline-ex command misses; cleared by flashClearMsg.

func (Model) Init

func (m Model) Init() tea.Cmd

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

func (m Model) Namespace() string

Namespace returns the active namespace filter.

func (Model) PaletteVisible

func (m Model) PaletteVisible() bool

PaletteVisible reports whether the modal command palette is open.

func (Model) PodsFilter added in v0.3.0

func (m Model) PodsFilter() string

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

func (m Model) SetLogTailStarter(f func(ns string, pods []string, sinceSeconds int64))

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

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

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

func (m Model) View() string

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.

Jump to

Keyboard shortcuts

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