Skip to content

Commit 27eaa8f

Browse files
committed
playbook: store playbook name in YAML
Previously, we always printed "60-second Linux analysis", even for macOS. Now, the title of the playbook is stored in the YAML file and it used in UI.
1 parent 6f84ae2 commit 27eaa8f

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

app/ui.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,25 @@ func (m *model) generateContent() string {
364364
cmdBuf.WriteString(cmdStr)
365365

366366
// Border the commands with a title (plain header, with spinner while running or a tick when finished)
367-
headerTitle := titleStyle.Render("60-second Linux analysis")
368367
var header string
369-
if m.execSeconds == 0 {
370-
header = fmt.Sprintf("%s %s", m.spin.View(), headerTitle)
368+
title := ""
369+
if m.toolbox != nil && m.toolbox.Playbook != nil && strings.TrimSpace(m.toolbox.Playbook.Name) != "" {
370+
title = m.toolbox.Playbook.Name
371+
}
372+
if title != "" {
373+
headerTitle := titleStyle.Render(title)
374+
if m.execSeconds == 0 {
375+
header = fmt.Sprintf("%s %s", m.spin.View(), headerTitle)
376+
} else {
377+
header = fmt.Sprintf("%s %s %s", successStyle.Render(iconSuccess), headerTitle, descStyle.Render(fmt.Sprintf("(finished in %.1f seconds)", m.execSeconds)))
378+
}
379+
}
380+
var commandsBox string
381+
if header != "" {
382+
commandsBox = header + "\n\n" + cmdBuf.String()
371383
} else {
372-
header = fmt.Sprintf("%s %s %s", successStyle.Render(iconSuccess), headerTitle, descStyle.Render(fmt.Sprintf("(finished in %.1f seconds)", m.execSeconds)))
384+
commandsBox = cmdBuf.String()
373385
}
374-
commandsBox := header + "\n\n" + cmdBuf.String()
375386

376387
// Assemble full UI
377388
var b strings.Builder

playbook/60-second-darwin.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
id: 60-second-darwin
2+
name: 60-second macOS analysis
23
system_prompt: |
34
### 60-second macOS analysis
45

playbook/60-second-linux.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
id: 60-second-linux
2+
name: 60-second Linux analysis
23
nixpkgs:
34
version: "380be19fbd2d9079f677978361792cb25e8a3635" # nixos-22.05 branch
45
packages:

playbook/playbook.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package playbook
22

33
type PlaybookConfig struct {
44
ID string `yaml:"id"`
5+
Name string `yaml:"name,omitempty"`
56
Nixpkgs struct {
67
Version string `yaml:"version"`
78
Packages []string `yaml:"packages"`

0 commit comments

Comments
 (0)