MCPcopy Index your code
hub / github.com/KevM/bubbleo

github.com/KevM/bubbleo @v0.1.5

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.5 ↗ · + Follow
98 symbols 218 edges 23 files 32 documented · 33%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

BubbleO

BubbleO is a collection of components for the excellent terminal UI tool bubbletea.

Go Reference

Navstack

Add support to your bubble tea application to easily transition between component models. The example below uses the menu component to let a user pick a color from a list of artist paintings.

Recording of the deeper example demo

    s := shell.New()
    s.Navstack.Push(navstack.NavigationItem{Model: m, Title: "Colors"})
    p := tea.NewProgram(s, tea.WithAltScreen())

    _, err := p.Run()
    if err != nil {
        fmt.Println("Error running program:", err)
        os.Exit(1)
    }

Push, well, pushes a new navigation item on the nav stack. The title is used for breadcrumbs (more later). The model at the top of the navstack has it's Update and View funcs used effectively making it the presented component on the stack.

Popping the stack will remove the topmost navigation item from the stack.

Navigation

Navigation is accomplished by your components when they publish messages like navstack.PushNavigation{} or navstack.PopNavigation{}.

Pushing a new component onto the stack

This example is from the included menu component which presents a list of choices. When a menu item is selected by pressing enter the choice's model is pushed onto the stack by publishing navstack.PushNavigation.

    case tea.KeyEnter.String():
        choice, ok := m.list.SelectedItem().(choiceItem)
        if ok {
            m.selected = &choice.key
            item := navstack.NavigationItem{Title: choice.title, Model: choice.key.Model}
            cmd := utils.Cmdize(navstack.PushNavigation{Item: item})
            return m, cmd
        }

There is no limit to the depth of the navigation stack. And the stack components may be dynamic based on your application and user needs.

Note: Cmdize simply wraps the given arg in a tea.Cmd (func that returns a tea.Msg)

Popping the stack

To pop a component off the stack you might do the following in your bubbletea Update func.

    case color.ColorSelected:
        pop := utils.Cmdize(navstack.PopNavigation{})
        cmd := utils.Cmdize(ArtistSelected{Name: m.Artist.Name, Color: msg.RGB})
        return m, tea.Sequence(pop, cmd)

The first cmd pops the current component off the stack while the second command is received by the previous component on the stack. This allows you to communicate the actions taken by the user up the nav stack.

If there are no items on the stack tea.Quit command is sent and the applicaiton exits.

Important: In this example we are using tea.Sequence rather than the normal tea.Batch to ensure the messages are played in the correct order. This ensures the pop is played before the ArtistSelected which means the component below on the stack will get the message after the navstack is update.

Menu

The menu component wraps the excellent The bubble/list component to let the user select from a menu of choices. Each choice is a model, title, and optional description which upon selection will take the user to this component's view. Menu expects to be used within a navigation stack. See the simple and deeper examples for detailed usage.

Breadcrumb

It is handy to give the user a sense of place by presenting a breadcrumb view showing them where they come from.

Checkout the deeper example for usage of breadcrumbs.

Shell

Finally the shell component emcapsulates the Breadcrumb and Navstack components allowing them to work together. See the simple and deeper examples to see how it works.

Extension points exported contracts — how you extend this code

Closable (Interface)
Closable is an interface for models that have resources that need to be cleaned up when they are no longer needed. The n [1 …
navstack/model.go

Core symbols most depended-on inside this repo

Cmdize
called by 14
utils/utils.go
Top
called by 8
navstack/model.go
SetSize
called by 6
menu/model.go
New
called by 4
menu/model.go
GetWindowSizeMsg
called by 3
window/model.go
Close
called by 3
navstack/model.go
Init
called by 3
navstack/model.go
Push
called by 3
navstack/model.go

Shape

Method 55
Struct 27
Function 15
Interface 1

Languages

Go100%

Modules by API surface

menu/model.go16 symbols
navstack/model.go12 symbols
breadcrumb/model.go7 symbols
window/model.go6 symbols
examples/deeper/artistpaintings/model.go6 symbols
shell/model.go5 symbols
navstack/messages.go5 symbols
examples/simple/main.go5 symbols
examples/deeper/paintingcolors/model.go5 symbols
examples/deeper/main.go5 symbols
navstack/navitem.go4 symbols
menu/keys.go4 symbols

For agents

$ claude mcp add bubbleo \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact