Skip to content

Weird interaction between bubbletea/glamour/bubble #405

@pme-openai

Description

@pme-openai

Describe the bug

When using the auto style, with the textinput bubble, it'll get wedged and start spewing OSC on the screen.

Setup

Please complete the following information along with version numbers, if applicable.

  • macOS 15.3.2
  • zsh
  • iTerm2

To Reproduce

Use the source below and run

$ go run main.go
bug
> ]11;rgb:0000/0000/0000\]11;rgb:0000/0000/0000\rgb:0000/0000/0000

Source Code

package main

import (
	"fmt"
	"os"
	"strings"

	"github.com/charmbracelet/bubbles/textinput"
	tea "github.com/charmbracelet/bubbletea"
	"github.com/charmbracelet/glamour"
	"github.com/charmbracelet/lipgloss"
)

type model struct{ input textinput.Model }

func (m model) Init() tea.Cmd { return nil }

func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
	var cmd tea.Cmd

	switch t := msg.(type) {
	case tea.KeyMsg:
		switch t.Type {
		case tea.KeyEsc:
			return m, tea.Quit
		}
	}
	m.input, cmd = m.input.Update(msg)

	return m, cmd
}

func (m model) View() string {
	if _, err := glamour.Render("", "auto"); err != nil {
		panic(err)
	}

	var sb strings.Builder
	sb.WriteString(lipgloss.NewStyle().Foreground(lipgloss.Color("1")).Render("bug"))
	sb.WriteString("\n")
	sb.WriteString(m.input.View())

	return sb.String()
}

func main() {
	input := textinput.New()
	input.Focus()

	p := tea.NewProgram(model{input})
	if _, err := p.Run(); err != nil {
		fmt.Printf("error: %v", err)
		os.Exit(1)
	}
}

Expected behavior

You should not see OSC output

Screenshots

Image

Additional context

If you switch from auto to e.g. dark, it works as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions