Index of every page on this site: llms.txt
All skills
meza avatar

/charm-tui

@982e21e
by mezameza/skills2 stars
Run it yourself

Design, build, refactor, and review Go terminal interfaces using Bubble Tea, Bubbles, Lip Gloss, and Bubblebook. Use whenever work involves Charm TUI components, message routing, focus, terminal layout, styling, component stories, or UI tests. Teaches one native v2 architecture with a coordinating root, reusable components, and isolated Bubblebook stories. Does not cover unrelated Charm services or authorize a v1 migration.

Use this Skill: https://skilld.dev/gh/meza/skills/charm-tui

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencestesting-runtime.md

≈1.1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Runtime integration tests

Read this when designing, building, reviewing, or testing behavior that depends on the real Bubble Tea runtime delivering commands and events.

If you have not selected the applicable test layers for the current task, read the testing guide first. Read every applicable guide it selects.

Keep the runtime harness small

The following complete test-file example proves one actual command round trip. It uses a tiny root because the runtime, rather than a reusable leaf, implements tea.Model. Project tests should pass their real root and controlled dependencies through the same setup.

package uitest

import (
    "bytes"
    "testing"
    "time"

    tea "charm.land/bubbletea/v2"
    "github.com/charmbracelet/colorprofile"
    "github.com/charmbracelet/x/exp/teatest/v2"
)

type completed struct{}
type runtimeRoot struct{ ready bool }

func (root runtimeRoot) Init() tea.Cmd {
    return func() tea.Msg { return completed{} }
}

func (root runtimeRoot) Update(message tea.Msg) (tea.Model, tea.Cmd) {
    switch message := message.(type) {
    case completed:
        root.ready = true
    case tea.KeyPressMsg:
        if message.String() == "q" {
            return root, tea.Quit
        }
    }
    return root, nil
}

func (root runtimeRoot) View() tea.View {
    if root.ready {
        return tea.NewView("ready")
    }
    return tea.NewView("loading")
}

func newRuntime(t testing.TB, root tea.Model) *teatest.TestModel {
    t.Helper()
    runtime := teatest.NewTestModel(t, root,
        teatest.WithInitialTermSize(40, 8),
        teatest.WithProgramOptions(
            tea.WithColorProfile(colorprofile.Ascii),
        ),
    )
    t.Cleanup(func() { runtime.GetProgram().Kill() })
    return runtime
}

func TestCommandReachesRoot(t *testing.T) {
    runtime := newRuntime(t, runtimeRoot{})
    teatest.WaitFor(t, runtime.Output(), func(output []byte) bool {
        return bytes.Contains(output, []byte("ready"))
    }, teatest.WithDuration(2*time.Second))

    runtime.Type("q")
    final := runtime.FinalModel(t, teatest.WithFinalTimeout(2*time.Second))
    root, ok := final.(runtimeRoot)
    if !ok || !root.ready {
        t.Fatalf("final model = %#v; want completed root", final)
    }
}

The runtime input and observation APIs serve different test needs:

API Purpose
WithInitialTermSize Fix the starting terminal dimensions
Send Inject a tea.Msg into the running program, including synthetic results, key events, or resize messages
Type Send text as key presses
Output and WaitFor Observe current or intermediate output until an explicit condition holds
FinalModel Inspect the model after the program finishes
FinalOutput Read remaining output after the program finishes
RequireEqualOutput Compare captured output with its golden expectation

For example, with runtime returned by teatest.NewTestModel and a root that handles resize messages:

runtime.Send(tea.WindowSizeMsg{Width: 20, Height: 6})

Unlike calling Update directly, Send crosses the real runtime message boundary. Assert the resulting layout through output or final model state. For an injected service result, send the application's actual typed message with the matching owner/request identity. Sending a result tests routing and handling; it does not prove the production service command produced that result. These input and observation APIs are defined in the teatest v2 source.

ASCII color profile removes color variability for this runtime-flow test. A color presentation test should pin its intended profile and theme instead. WaitFor consumes output while observing it, so do not expect a later FinalOutput read to contain the already-read prefix. Use separate tests or an explicit capture when asserting the full stream.

Keep the experimental dependency pinned and centralize only stable setup such as size, profile, and cleanup. The teatest v2 source defines these observation APIs; Bubble Tea defines the program options. Do not grow this setup into another event framework.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    The Charm TUI skill provides architectural guidance and practical examples for building terminal user interfaces in Go using the Bubble Tea ecosystem. It promotes best practices like component isolation, deterministic rendering, and comprehensive testing. No malicious code, data exfiltration, or obfuscation patterns were detected.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at 982e21e. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 weeks ago.

Activeupdated 3 months ago

README badge

README badge for meza/skills/charm-tui