Skip to content

Commit 4705fcd

Browse files
authored
More compact home screen (#56)
Co-authored-by: Tomas Vesely <448809+wham@users.noreply.github.com>
1 parent 234415c commit 4705fcd

2 files changed

Lines changed: 58 additions & 65 deletions

File tree

main.go

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -76,26 +76,33 @@ var (
7676

7777
// renderTitleBar renders a title bar with left title and right-aligned user status
7878
func renderTitleBar(screen, username, organization string, innerWidth int) string {
79-
leftTitle := fmt.Sprintf("GitHub Brain %s / %s", Version, screen)
80-
var rightStatus string
79+
leftTitle := fmt.Sprintf("GitHub Brain / %s", screen)
80+
81+
// Build right side: @username · 🏢 org · version
82+
var rightParts []string
8183
if username != "" {
82-
if organization != "" {
83-
rightStatus = fmt.Sprintf("👤 @%s (%s)", username, organization)
84-
} else {
85-
rightStatus = fmt.Sprintf("👤 @%s (no org)", username)
86-
}
87-
} else {
88-
rightStatus = "👤 Not logged in"
84+
rightParts = append(rightParts, fmt.Sprintf("👤 @%s", username))
85+
}
86+
if organization != "" {
87+
rightParts = append(rightParts, fmt.Sprintf("🏢 %s", organization))
88+
}
89+
90+
// Join parts with separator
91+
rightStatus := strings.Join(rightParts, " · ")
92+
if rightStatus != "" {
93+
rightStatus += " · "
8994
}
9095

9196
leftWidth := lipgloss.Width(leftTitle)
92-
rightWidth := lipgloss.Width(rightStatus)
97+
versionText := Version
98+
versionWidth := lipgloss.Width(versionText)
99+
rightWidth := lipgloss.Width(rightStatus) + versionWidth
93100
spacing := innerWidth - leftWidth - rightWidth
94101
if spacing < 1 {
95102
spacing = 1
96103
}
97104

98-
return titleStyle.Render(leftTitle) + strings.Repeat(" ", spacing) + titleStyle.Render(rightStatus)
105+
return titleStyle.Render(leftTitle) + strings.Repeat(" ", spacing) + titleStyle.Render(rightStatus) + dimStyle.Render(versionText)
99106
}
100107

101108
// Removed ConsoleHandler - not needed with Bubble Tea
@@ -4814,7 +4821,7 @@ func (m model) View() string {
48144821
}
48154822

48164823
// Add title as first line of content
4817-
leftTitle := fmt.Sprintf("GitHub Brain %s / 📥 Pull", Version)
4824+
leftTitle := fmt.Sprintf("GitHub Brain %s / 🔄 Pull", Version)
48184825
var rightStatus string
48194826
if m.username != "" {
48204827
if m.organization != "" {
@@ -4960,9 +4967,9 @@ func newMainMenuModel(homeDir string) mainMenuModel {
49604967
return mainMenuModel{
49614968
homeDir: homeDir,
49624969
choices: []menuChoice{
4963-
{icon: "🔧", name: "Setup", description: "Configure authentication and settings"},
4964-
{icon: "📥", name: "Pull", description: "Sync GitHub data to local database"},
4965-
{icon: "🚪", name: "Quit", description: "Exit"},
4970+
{icon: "🔧", name: "Setup", description: "Configure GitHub username and organization"},
4971+
{icon: "🔄", name: "Pull", description: "Sync GitHub data to local database"},
4972+
{icon: "🚪", name: "Quit", description: "Ctrl+C"},
49664973
},
49674974
cursor: 0,
49684975
status: "Checking authentication...",
@@ -5084,28 +5091,23 @@ func (m mainMenuModel) View() string {
50845091
b.WriteString("\n")
50855092

50865093
// Menu items
5094+
selectorStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("12")) // Blue selector
50875095
for i, choice := range m.choices {
50885096
cursor := " "
5089-
style := dimStyle
5097+
descStyle := dimStyle
50905098
if m.cursor == i {
5091-
cursor = "> "
5092-
style = selectedStyle
5099+
cursor = selectorStyle.Render("▶") + " "
5100+
descStyle = selectedStyle
50935101
}
5094-
line := fmt.Sprintf("%s%s %s", cursor, choice.icon, choice.name)
5095-
if choice.description != "" {
5096-
line += " " + choice.description
5097-
}
5098-
b.WriteString(style.Render(line) + "\n")
5102+
// Pad name to 5 characters for alignment
5103+
paddedName := fmt.Sprintf("%-5s", choice.name)
5104+
// Name is always bold (titleStyle), description uses current selection style
5105+
b.WriteString(fmt.Sprintf("%s%s %s %s", cursor, choice.icon, titleStyle.Render(paddedName), descStyle.Render(choice.description)))
50995106
if i < len(m.choices)-1 {
5100-
b.WriteString("\n")
5107+
b.WriteString("\n\n")
51015108
}
51025109
}
51035110

5104-
b.WriteString("\n")
5105-
5106-
// Help text
5107-
b.WriteString(dimStyle.Render("Press Enter to select, Ctrl+C to quit"))
5108-
51095111
// Create border style
51105112
borderStyle := lipgloss.NewStyle().
51115113
Border(lipgloss.RoundedBorder()).
@@ -5457,7 +5459,7 @@ func (m orgPromptModel) View() string {
54575459

54585460
var b strings.Builder
54595461

5460-
b.WriteString(titleStyle.Render(fmt.Sprintf("GitHub Brain %s / 📥 Pull", Version)) + "\n")
5462+
b.WriteString(titleStyle.Render(fmt.Sprintf("GitHub Brain %s / 🔄 Pull", Version)) + "\n")
54615463
b.WriteString("\n")
54625464
b.WriteString(" Enter your GitHub organization:\n")
54635465
b.WriteString(" " + m.textInput.View() + "\n")

main.md

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -33,73 +33,64 @@ When `github-brain` is run without arguments, display an interactive menu:
3333

3434
```
3535
╭────────────────────────────────────────────────────────────────╮
36-
│ GitHub Brain 1.0.0 / 🏠 Home 👤 Not logged in │
37-
│ │
38-
│ > 🔧 Setup Configure authentication and settings │
39-
│ 📥 Pull Sync GitHub data to local database │
40-
│ 🚪 Quit Exit │
41-
│ │
42-
│ Press Enter to select, Ctrl+C to quit │
36+
│ GitHub Brain / 🏠 Home 1.0.0 │
4337
│ │
38+
│ ▶ 🔧 Setup Configure GitHub username and organization │
39+
│ 🔄 Pull Sync GitHub data to local database │
40+
│ 🚪 Quit Ctrl+C │
4441
╰────────────────────────────────────────────────────────────────╯
4542
```
4643

4744
After login but no organization configured:
4845

4946
```
5047
╭────────────────────────────────────────────────────────────────╮
51-
│ GitHub Brain 1.0.0 / 🏠 Home 👤 @wham (no org) │
52-
│ │
53-
│ > 🔧 Setup Configure authentication and settings │
54-
│ 📥 Pull Sync GitHub data to local database │
55-
│ 🚪 Quit Exit │
56-
│ │
57-
│ Press Enter to select, Ctrl+C to quit │
48+
│ GitHub Brain / 🏠 Home 👤 @wham · 1.0.0 │
5849
│ │
50+
│ ▶ 🔧 Setup Configure GitHub username and organization │
51+
│ 🔄 Pull Sync GitHub data to local database │
52+
│ 🚪 Quit Ctrl+C │
5953
╰────────────────────────────────────────────────────────────────╯
6054
```
6155

6256
After successful login with organization configured:
6357

6458
```
6559
╭────────────────────────────────────────────────────────────────╮
66-
│ GitHub Brain 1.0.0 / 🏠 Home 👤 @wham (my-org) │
67-
│ │
68-
│ 🔧 Setup Configure authentication and settings │
69-
│ > 📥 Pull Sync GitHub data to local database │
70-
│ 🚪 Quit Exit │
71-
│ │
72-
│ Press Enter to select, Ctrl+C to quit │
60+
│ GitHub Brain / 🏠 Home 👤 @wham · 🏢 my-org · 1.0.0 │
7361
│ │
62+
│ 🔧 Setup Configure GitHub username and organization │
63+
│ ▶ 🔄 Pull Sync GitHub data to local database │
64+
│ 🚪 Quit Ctrl+C │
7465
╰────────────────────────────────────────────────────────────────╯
7566
```
7667

7768
### Title Bar Format
7869

7970
The title bar contains:
8071

81-
- Left side: `GitHub Brain <version> / <emoji> <screen>`
82-
- Right side: `👤 <status>` (right-aligned)
72+
- Left side: `GitHub Brain / <emoji> <screen>`
73+
- Right side: `👤 @<username> · 🏢 <org> · <version>` (right-aligned, version in dim style)
8374

84-
User status values:
75+
Right side components (shown only when available):
8576

86-
- `👤 Not logged in` - No GITHUB_TOKEN in .env or token invalid
87-
- `👤 @username (no org)` - Token valid but no organization configured
88-
- `👤 @username (org)` - Token and organization configured
77+
- `👤 @username` - Shown when logged in
78+
- `🏢 org` - Shown when organization is configured
79+
- `<version>` - Always shown, in dim style
8980

9081
### Menu Navigation
9182

9283
- Use arrow keys (↑/↓) or j/k to navigate
9384
- Press Enter to select
9485
- Press Esc to go back (in submenus)
9586
- Press Ctrl+C to quit
96-
- Highlight current selection with `>`
87+
- Highlight current selection with `` (blue)
9788

9889
### Menu Items
9990

10091
1. **🔧 Setup** - Opens the setup submenu (see [Setup Menu](#setup-menu) section)
101-
2. **📥 Pull** - Runs the pull operation (see [pull](#pull) section)
102-
3. **🚪 Quit** - Exit the application
92+
2. **🔄 Pull** - Runs the pull operation (see [pull](#pull) section)
93+
3. **🚪 Quit** - Exit the application (Ctrl+C)
10394

10495
### Default Selection
10596

@@ -388,7 +379,7 @@ Console at the beginning of pull:
388379

389380
```
390381
╭────────────────────────────────────────────────────────────────╮
391-
│ GitHub Brain 1.0.0 / 📥 Pull 👤 @wham (my-org) │
382+
│ GitHub Brain 1.0.0 / 🔄 Pull 👤 @wham (my-org) │
392383
│ │
393384
│ 📋 Repositories │
394385
│ 📋 Discussions │
@@ -412,7 +403,7 @@ Console during first item pull:
412403

413404
```
414405
╭────────────────────────────────────────────────────────────────╮
415-
│ GitHub Brain 1.0.0 / 📥 Pull 👤 @wham (my-org) │
406+
│ GitHub Brain 1.0.0 / 🔄 Pull 👤 @wham (my-org) │
416407
│ │
417408
│ ⠋ Repositories: 1,247 │
418409
│ 📋 Discussions │
@@ -436,7 +427,7 @@ Console when first item completes:
436427

437428
```
438429
╭────────────────────────────────────────────────────────────────╮
439-
│ GitHub Brain 1.0.0 / 📥 Pull 👤 @wham (my-org) │
430+
│ GitHub Brain 1.0.0 / 🔄 Pull 👤 @wham (my-org) │
440431
│ │
441432
│ ✅ Repositories: 2,847 │
442433
│ ⠙ Discussions: 156 │
@@ -460,7 +451,7 @@ Console when an error occurs:
460451

461452
```
462453
╭────────────────────────────────────────────────────────────────╮
463-
│ GitHub Brain 1.0.0 / 📥 Pull 👤 @wham (my-org) │
454+
│ GitHub Brain 1.0.0 / 🔄 Pull 👤 @wham (my-org) │
464455
│ │
465456
│ ✅ Repositories: 2,847 │
466457
│ ❌ Discussions: 156 (errors) │
@@ -1317,7 +1308,7 @@ Download the appropriate archive for your platform from [releases](https://githu
13171308

13181309
```bash
13191310
# Specific version
1320-
curl -L https://github.com/wham/github-brain/releases/download/v1.2.3/github-brain-darwin-arm64.tar.gz | tar xz
1311+
curl -L https://github.com/wham/github-brain/releases/download/v1.2.3/github-brain-darwin-arm64.tar.gz · tar xz
13211312
```
13221313

13231314
## Code Quality

0 commit comments

Comments
 (0)