Skip to content

Commit 3c45b47

Browse files
authored
Don't render emojis in text mode (#776)
1 parent f6b7dd5 commit 3c45b47

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

cmd/preflight/job_presenter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ func (p jobPresenter) failParts(j buildkite.Job) (symbol, name, detail string) {
4141

4242
func (p jobPresenter) Line(j buildkite.Job) string {
4343
symbol, name, detail := p.failParts(j)
44-
return fmt.Sprintf("%s %s %s", symbol, emoji.Render(name), detail)
44+
return fmt.Sprintf("%s %s %s", symbol, name, detail)
4545
}
4646

4747
func (p jobPresenter) PassedLine(j buildkite.Job) string {
48-
name := emoji.Render(watch.NewFormattedJob(j).DisplayName())
48+
name := watch.NewFormattedJob(j).DisplayName()
4949
return fmt.Sprintf("✔ %s", name)
5050
}
5151

cmd/preflight/tty.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,15 @@ func (m ttyModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
7474
}
7575

7676
case EventBuildSummary:
77-
// Store the summary on the model so View() renders it as the
78-
// final frame when the program quits via Close().
77+
// Print the summary via Printf (which scrolls it above the
78+
// view) instead of rendering it through View(). Inline-image
79+
// escape sequences from emoji.Render confuse Bubbletea's
80+
// cursor tracking, causing lines to vanish on re-render.
7981
m.summary = &msg
80-
return m, nil
82+
return m, tea.Sequence(
83+
tea.Printf("%s", buildSummaryView(msg)),
84+
tea.Quit,
85+
)
8186

8287
case EventTestFailure:
8388
if len(msg.TestFailures) > 0 {
@@ -129,10 +134,6 @@ func (m ttyModel) hardwrapLine(s string) string {
129134
func (m ttyModel) render() string {
130135
separator := ttyBorderStyle.Render("─────────────────────────────────────────────")
131136

132-
if m.summary != nil {
133-
return buildSummaryView(*m.summary)
134-
}
135-
136137
statusLine := fmt.Sprintf(" %s %s", m.spinner.View(), ttyStatusStyle.Render(m.statusText()))
137138

138139
if m.latest.Jobs == nil {
@@ -161,6 +162,11 @@ func (m ttyModel) render() string {
161162
}
162163

163164
func (m ttyModel) View() string {
165+
if m.summary != nil {
166+
// Summary was already printed via tea.Printf; return empty
167+
// so Bubbletea clears the spinner area on exit.
168+
return ""
169+
}
164170
return m.hardwrapLine(m.render())
165171
}
166172

0 commit comments

Comments
 (0)