Skip to content

Commit 7636f50

Browse files
skarimCopilot
andcommitted
more detailed help instructions
Co-authored-by: Copilot <copilot@github.com>
1 parent 8e11fdb commit 7636f50

6 files changed

Lines changed: 63 additions & 49 deletions

File tree

cmd/modify.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func printModifySuccess(cfg *config.Config, result *modifyview.ApplyResult) {
164164
}
165165

166166
cfg.Printf("")
167-
cfg.Printf("Run `%s` to push branches and recreate the stack on GitHub",
167+
cfg.Printf("Run `%s` to push your changes and update the stack of PRs on GitHub",
168168
cfg.ColorCyan("gh stack submit"))
169169
}
170170

internal/modify/apply.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,13 @@ func ContinueApply(
587587
cfg.Printf(" %s", f)
588588
}
589589
}
590-
return fmt.Errorf("rebase conflict on %s — resolve and run `gh stack modify --continue` again", branchName)
590+
cfg.Printf("")
591+
cfg.Printf("Resolve the conflicts, stage with `%s`, then run `%s`",
592+
cfg.ColorCyan("git add <file>"),
593+
cfg.ColorCyan("gh stack modify --continue"))
594+
cfg.Printf("Or restore the stack with `%s`",
595+
cfg.ColorCyan("gh stack modify --recover"))
596+
return fmt.Errorf("rebase conflict on %s", branchName)
591597
}
592598

593599
cfg.Successf("Rebased %s onto %s", branchName, newBase)
@@ -619,8 +625,9 @@ func ContinueApply(
619625
cfg.Warningf("failed to save stack: %v", err)
620626
}
621627

622-
cfg.Successf("Modify apply completed")
623-
cfg.Printf("Run `%s` to push branches and recreate the stack on GitHub",
628+
cfg.Successf("Stack modified successfully")
629+
cfg.Printf("")
630+
cfg.Printf("Run `%s` to push your changes and update the stack of PRs on GitHub",
624631
cfg.ColorCyan("gh stack submit"))
625632
return nil
626633
}

internal/tui/modifyview/help.go

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,58 @@ import (
66
"github.com/charmbracelet/lipgloss"
77
)
88

9-
type helpEntry struct {
10-
keys string
11-
desc string
12-
}
13-
14-
var helpEntries = []helpEntry{
15-
{"↑/↓, k/j", "Select branch"},
16-
{"f", "View files changed"},
17-
{"c", "View commits"},
18-
{"x", "Drop branch from stack"},
19-
{"r", "Rename branch"},
20-
{"u", "Fold up (merge into branch above)"},
21-
{"d", "Fold down (merge into branch below)"},
22-
{"shift+↑/↓, K/J", "Reorder branch up/down"},
23-
{"z", "Undo last action"},
24-
{"ctrl+s", "Apply all changes"},
25-
{"q/esc", "Cancel and exit (abandon changes)"},
26-
}
27-
28-
// renderHelpOverlay renders a centered help overlay.
9+
// renderHelpOverlay renders a centered help overlay with a guide to modify operations.
2910
func renderHelpOverlay(width, height int) string {
3011
var b strings.Builder
3112

32-
title := helpTitleStyle.Render("Keyboard Shortcuts")
13+
title := helpTitleStyle.Render("Modify Stack")
3314
b.WriteString(title)
34-
b.WriteString("\n\n")
15+
b.WriteString("\n")
16+
b.WriteString(helpDescStyle.Render("Restructure your stack by dropping, folding, renaming, or reordering branches."))
17+
b.WriteString("\n")
3518

36-
maxKeyWidth := 0
37-
for _, e := range helpEntries {
38-
w := lipgloss.Width(e.keys)
39-
if w > maxKeyWidth {
40-
maxKeyWidth = w
41-
}
19+
sections := []struct {
20+
heading string
21+
body string
22+
}{
23+
{
24+
"Drop (x)",
25+
"Remove a branch and its commits from the stack.\nThe local branch is preserved; the PR stays open on GitHub.",
26+
},
27+
{
28+
"Fold up / down (u / d)",
29+
"Merge a branch's commits into an adjacent branch.\nFold up absorbs into the branch above; fold down into the branch below.",
30+
},
31+
{
32+
"Rename (r)",
33+
"Rename a branch locally. The new name is pushed on submit.",
34+
},
35+
{
36+
"Reorder (Shift+↑/↓)",
37+
"Move a branch up or down in the stack.\nA cascading rebase adjusts all affected branches.",
38+
},
4239
}
4340

44-
for _, e := range helpEntries {
45-
keyVisWidth := lipgloss.Width(e.keys)
46-
keyPad := strings.Repeat(" ", maxKeyWidth-keyVisWidth+2)
47-
b.WriteString(helpKeyStyle.Render(e.keys))
48-
b.WriteString(keyPad)
49-
b.WriteString(helpDescStyle.Render(e.desc))
41+
for _, s := range sections {
5042
b.WriteString("\n")
43+
b.WriteString(helpKeyStyle.Render(s.heading))
44+
b.WriteString("\n")
45+
for _, line := range strings.Split(s.body, "\n") {
46+
b.WriteString(helpDescStyle.Render(line))
47+
b.WriteString("\n")
48+
}
5149
}
5250

5351
b.WriteString("\n")
52+
b.WriteString(helpKeyStyle.Render("Applying changes"))
53+
b.WriteString("\n")
54+
b.WriteString(helpDescStyle.Render("Press " + helpKeyStyle.Render("Ctrl+S") + " to apply all staged changes. Nothing is modified until you save."))
55+
b.WriteString("\n")
56+
b.WriteString(helpDescStyle.Render("If you have open PRs, run ") + helpKeyStyle.Render("gh stack submit") + helpDescStyle.Render(" afterwards to push the updated"))
57+
b.WriteString("\n")
58+
b.WriteString(helpDescStyle.Render("branches and recreate the stack of PRs on GitHub."))
59+
60+
b.WriteString("\n\n")
5461
b.WriteString(statusBarStyle.Render("Press ? or Esc to close"))
5562

5663
content := b.String()

internal/tui/shared/header.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ const ArtDisplayWidth = 20
5151

5252
// HeaderConfig controls what the header displays.
5353
type HeaderConfig struct {
54-
ShowArt bool // true for View (GitHub logo), false for Modify
55-
Title string // "GitHub Stacks" or "Modify Mode"
56-
Subtitle string // version string, or empty
57-
InfoLines []HeaderInfoLine // info rows (stack info)
58-
Shortcuts []ShortcutEntry // keyboard shortcuts
59-
ShortcutColumns int // number of columns for shortcuts (default 1; set 2 for side-by-side)
54+
ShowArt bool // whether to display GitHub logo
55+
Title string // heading next to logo art
56+
Subtitle string // version string, or empty
57+
InfoLines []HeaderInfoLine // info rows (stack info)
58+
Shortcuts []ShortcutEntry // keyboard shortcuts
59+
ShortcutColumns int // number of columns for shortcuts (default 1; set 2 for side-by-side)
6060
}
6161

6262
// ShouldShowHeader returns whether the header should be displayed.

internal/tui/stackview/model.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ func (m Model) buildHeaderConfig() shared.HeaderConfig {
409409

410410
return shared.HeaderConfig{
411411
ShowArt: true,
412-
Title: "GitHub Stacks",
412+
Title: "View Stack",
413413
Subtitle: "v" + m.version,
414414
InfoLines: []shared.HeaderInfoLine{
415415
{Icon: "✓", Label: "Stack initialized"},

internal/tui/stackview/model_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func TestView_HeaderShownWhenTallEnough(t *testing.T) {
184184
view := m.View()
185185
assert.Contains(t, view, "┌")
186186
assert.Contains(t, view, "┘")
187-
assert.Contains(t, view, "GitHub Stacks")
187+
assert.Contains(t, view, "View Stack")
188188
assert.Contains(t, view, "v0.0.1")
189189
assert.Contains(t, view, "Base: main")
190190
assert.Contains(t, view, "2 branches")
@@ -203,7 +203,7 @@ func TestView_HeaderHiddenWhenShort(t *testing.T) {
203203
view := m.View()
204204
// Should NOT contain header box
205205
assert.NotContains(t, view, "┌")
206-
assert.NotContains(t, view, "GitHub Stacks")
206+
assert.NotContains(t, view, "View Stack")
207207
// Should NOT contain help bar either (hints are only in header)
208208
assert.NotContains(t, view, "commits")
209209
}
@@ -218,7 +218,7 @@ func TestView_HeaderHiddenWhenNarrow(t *testing.T) {
218218

219219
view := m.View()
220220
assert.NotContains(t, view, "┌")
221-
assert.NotContains(t, view, "GitHub Stacks")
221+
assert.NotContains(t, view, "View Stack")
222222
}
223223

224224
func TestView_HeaderWithoutShortcutsWhenMediumWidth(t *testing.T) {
@@ -231,7 +231,7 @@ func TestView_HeaderWithoutShortcutsWhenMediumWidth(t *testing.T) {
231231

232232
view := m.View()
233233
assert.Contains(t, view, "┌", "header should be shown")
234-
assert.Contains(t, view, "GitHub Stacks", "info should be shown")
234+
assert.Contains(t, view, "View Stack", "info should be shown")
235235
assert.NotContains(t, view, "checkout", "shortcuts should be hidden at this width")
236236
}
237237

0 commit comments

Comments
 (0)