Skip to content

Commit 0e753fd

Browse files
gitcoder89431claude
andcommitted
feat: context-aware footer on Connect screen
- r (rename) removed from footer, still visible in ? overlay - a (accept) and i (ignore) only appear in footer when pending devices exist - FooterBindings() interface pattern so other screens can opt into the same Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3af6e9e commit 0e753fd

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

internal/app/view.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ func (m Model) View() tea.View {
2525

2626
head := header.View(header.Model{AppName: config.AppName, DeviceID: m.deviceID, DeviceName: m.deviceName, SyncStatus: m.syncStatus}, dims.Header.Width, dims.Header.Height, m.theme)
2727
footBindings := m.keys.ShortHelp()
28-
if screenBindings := active.KeyBindings(); len(screenBindings) > 0 {
28+
type footerBinder interface{ FooterBindings() []key.Binding }
29+
if fb, ok := active.(footerBinder); ok {
30+
footBindings = fb.FooterBindings()
31+
} else if screenBindings := active.KeyBindings(); len(screenBindings) > 0 {
2932
footBindings = screenBindings
3033
}
3134
foot := footer.View(footBindings, dims.Footer.Width, dims.Footer.Height, m.theme)

internal/screens/connections.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,29 @@ func (c Connections) KeyBindings() []key.Binding {
351351
key.NewBinding(key.WithKeys("j", "k"), key.WithHelp("j/k", "navigate")),
352352
key.NewBinding(key.WithKeys("r"), key.WithHelp("r", "rename")),
353353
key.NewBinding(key.WithKeys("p"), key.WithHelp("p", "pair by ID")),
354-
key.NewBinding(key.WithKeys("a"), key.WithHelp("a", "accept")),
354+
key.NewBinding(key.WithKeys("a"), key.WithHelp("a", "accept pending")),
355355
key.NewBinding(key.WithKeys("i"), key.WithHelp("i", "ignore pending")),
356356
key.NewBinding(key.WithKeys("d"), key.WithHelp("d", "remove device")),
357357
}
358358
}
359359

360+
// FooterBindings returns a shorter, context-aware binding set for the footer.
361+
// r is omitted (available via ? only); a/i only appear when pending devices exist.
362+
func (c Connections) FooterBindings() []key.Binding {
363+
bindings := []key.Binding{
364+
key.NewBinding(key.WithKeys("j", "k"), key.WithHelp("j/k", "navigate")),
365+
key.NewBinding(key.WithKeys("p"), key.WithHelp("p", "pair by ID")),
366+
key.NewBinding(key.WithKeys("d"), key.WithHelp("d", "remove device")),
367+
}
368+
if len(c.pending) > 0 {
369+
bindings = append(bindings,
370+
key.NewBinding(key.WithKeys("a"), key.WithHelp("a", "accept")),
371+
key.NewBinding(key.WithKeys("i"), key.WithHelp("i", "ignore")),
372+
)
373+
}
374+
return bindings
375+
}
376+
360377
// firstSegment returns just the first 7-char segment of a Syncthing device ID.
361378
func firstSegment(id string) string {
362379
if idx := strings.Index(id, "-"); idx > 0 {

0 commit comments

Comments
 (0)