Advertise the rule screens in the key help

The bottom help still described 4 as "rules" from before the rules list
existed, and never mentioned 5 at all, so the new screen was unreachable
unless you already knew about it.

The transactions line had also outgrown the window: at 137 characters it ran
past the edge of a normal terminal and "q quit" was simply gone. Help now
wraps to the window width instead of being cut off, and that line is shorter.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-09 02:09:42 +02:00
co-authored by Claude Opus 5
parent c2eba53fd4
commit 3eca8f5376
3 changed files with 62 additions and 6 deletions
+49
View File
@@ -840,6 +840,55 @@ func TestRuleListPruneWithNothingToDo(t *testing.T) {
}
}
// Every screen must advertise how to reach the others and how to quit. These
// lines drift as screens are added, and a line that outgrows the terminal
// loses its tail silently.
func TestHelpLinesMentionEveryScreen(t *testing.T) {
m, _ := newTestModel(t)
for _, tc := range []struct {
name string
key string
want []string
}{
{"accounts", "1", []string{"4 new rule", "5 rules", "q quit"}},
{"transactions", "2", []string{"4 new rule", "5 rules", "q quit"}},
{"report", "3", []string{"4 new rule", "5 rules", "q quit"}},
{"rules", "5", []string{"d delete rule", "p prune all unused", "4 new rule", "q quit"}},
} {
key(t, m, tc.key)
help := m.help()
for _, want := range tc.want {
if !strings.Contains(help, want) {
t.Errorf("%s help = %q, missing %q", tc.name, help, want)
}
}
}
// The rule builder is a form, so it advertises its own keys instead.
key(t, m, "4")
if help := m.help(); !strings.Contains(help, "enter save rule") || !strings.Contains(help, "esc back") {
t.Errorf("rule builder help = %q", help)
}
}
// A help line longer than the window must wrap, not be cut off.
func TestHelpWrapsOnNarrowTerminals(t *testing.T) {
m, _ := newTestModel(t)
key(t, m, "2")
m.Update(tea.WindowSizeMsg{Width: 90, Height: 30})
view := m.View()
if !strings.Contains(view, "q quit") {
t.Errorf("the end of the help line was lost at 90 columns:\n%s", view)
}
for _, line := range strings.Split(view, "\n") {
if len([]rune(line)) > 90 {
t.Errorf("line is %d columns wide, wider than the window:\n%q", len([]rune(line)), line)
}
}
}
// newEmptyModel builds a model over an index with nothing in it.
func newEmptyModel(t *testing.T, accounts []*config.Account) *Model {
t.Helper()