Skip to content

mission control for agent skills

Inventory nav: add vim gg/G top-bottom jumps, drop direct P/G scope keys

Alvin Unreal06615ad06dbc
diff --git a/internal/tui/state.go b/internal/tui/state.go
index f89dfab..bd01767 100644
--- a/internal/tui/state.go
+++ b/internal/tui/state.go
@@ -184,6 +184,37 @@ func (m *appModel) clampSelection() {
}
}
+// jumpListTop / jumpListBottom move to the start/end of whichever pane has
+// focus: the inventory selection, or the metadata/preview scroll position.
+// clampSelection (called after key handling) fixes the empty-list case.
+func (m *appModel) jumpListTop() {
+ switch m.focus {
+ case focusMetadata:
+ m.metadataViewport.GotoTop()
+ case focusPreview:
+ m.previewViewport.GotoTop()
+ default:
+ m.selected = 0
+ m.actionResult = nil
+ m.metadataViewport.GotoTop()
+ m.previewViewport.GotoTop()
+ }
+}
+
+func (m *appModel) jumpListBottom() {
+ switch m.focus {
+ case focusMetadata:
+ m.metadataViewport.GotoBottom()
+ case focusPreview:
+ m.previewViewport.GotoBottom()
+ default:
+ m.selected = len(m.visibleRows()) - 1
+ m.actionResult = nil
+ m.metadataViewport.GotoTop()
+ m.previewViewport.GotoTop()
+ }
+}
+
func (m appModel) isCollapsed(group string) bool {
if m.collapsedGroups == nil {
return false
diff --git a/internal/tui/tui.go b/internal/tui/tui.go
index 9ea93d7..7fa6ca0 100644
--- a/internal/tui/tui.go
+++ b/internal/tui/tui.go
@@ -80,6 +80,7 @@ type appModel struct {
discovery map[string]SourceDiscovery
modalSelected int
modalSource string
+ pendingG bool // saw a lone "g"; a second "g" jumps to top
}
type paneLayout struct {
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go
index 4685845..b3847a3 100644
--- a/internal/tui/tui_test.go
+++ b/internal/tui/tui_test.go
@@ -769,19 +769,42 @@ func TestScopeFilterKeys(t *testing.T) {
if next.filter != scopeAll {
t.Fatalf("expected F to reset scope to All, got %d", next.filter)
}
+}
- // Test 'P' sets Project-only
- updated, _ = next.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'P'}})
- next = updated.(appModel)
- if next.filter != scopeProject {
- t.Fatalf("expected P to set project scope, got %d", next.filter)
+func TestTopBottomJumpKeys(t *testing.T) {
+ m := appModel{width: 120, height: 32, result: model.ScanResult{Skills: []*model.Skill{
+ {Name: "One", Scope: model.ScopeProject},
+ {Name: "Two", Scope: model.ScopeProject},
+ {Name: "Three", Scope: model.ScopeProject},
+ }}}
+ last := len(m.visibleRows()) - 1
+
+ // 'G' jumps to the bottom.
+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'G'}})
+ next := updated.(appModel)
+ if next.selected != last {
+ t.Fatalf("expected G to select last row %d, got %d", last, next.selected)
}
- // Test 'G' sets Global-only
- updated, _ = next.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'G'}})
- next = updated.(appModel)
- if next.filter != scopeGlobal {
- t.Fatalf("expected G to set global scope, got %d", next.filter)
+ // A lone 'g' arms but does not move selection.
+ updated, _ = next.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'g'}})
+ armed := updated.(appModel)
+ if armed.selected != last || !armed.pendingG {
+ t.Fatalf("expected lone g to arm without moving, got selected=%d pendingG=%v", armed.selected, armed.pendingG)
+ }
+
+ // The second 'g' jumps to the top and disarms.
+ updated, _ = armed.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'g'}})
+ top := updated.(appModel)
+ if top.selected != 0 || top.pendingG {
+ t.Fatalf("expected gg to select first row and disarm, got selected=%d pendingG=%v", top.selected, top.pendingG)
+ }
+
+ // A non-g key disarms a pending g.
+ updated, _ = next.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'g'}})
+ updated, _ = updated.(appModel).Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'k'}})
+ if updated.(appModel).pendingG {
+ t.Fatal("expected a non-g key to disarm pendingG")
}
}
diff --git a/internal/tui/update.go b/internal/tui/update.go
index 1a7b4f6..f09d3a9 100644
--- a/internal/tui/update.go
+++ b/internal/tui/update.go
@@ -277,6 +277,10 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, nil
}
+ // "gg" jumps to top: a lone g arms the flag, any other key disarms it.
+ gPending := m.pendingG
+ m.pendingG = false
+
switch key {
case "esc":
if m.selectedCount() > 0 {
@@ -405,16 +409,6 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case "3":
m.focus = focusPreview
m.detailsFocused = true
- case "P":
- m.filter = scopeProject
- m.selected = 0
- m.actionResult = nil
- m.viewport.GotoTop()
- case "G":
- m.filter = scopeGlobal
- m.selected = 0
- m.actionResult = nil
- m.viewport.GotoTop()
case "f":
m.filter = (m.filter + 1) % 3
m.selected = 0
@@ -511,13 +505,17 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
return m, cmd
case "home":
- if m.focus == focusMetadata {
- m.metadataViewport.GotoTop()
- } else if m.focus == focusPreview {
- m.previewViewport.GotoTop()
+ m.jumpListTop()
+ case "end":
+ m.jumpListBottom()
+ case "g":
+ if gPending {
+ m.jumpListTop()
} else {
- m.previewViewport.GotoTop()
+ m.pendingG = true
}
+ case "G":
+ m.jumpListBottom()
}
m.clampSelection()
m.clampAction()
diff --git a/internal/tui/view.go b/internal/tui/view.go
index 22da053..228eab9 100644
--- a/internal/tui/view.go
+++ b/internal/tui/view.go
@@ -1168,6 +1168,7 @@ func (m appModel) helpModalOverlay(layout appLayout) string {
"",
sectionHeaderStyle.Render("Navigation & Focus:"),
" ↑/↓, j/k Move selection (Inventory focus) or scroll (Metadata/Preview)",
+ " gg / G Jump to top / bottom (also home / end)",
" 1 / 2 / 3 Focus Inventory (1), Metadata (2), or Preview (3) pane",
" tab / shift-tab Cycle focus forward / backward through panes",
" ← / → Move focus backward / forward outside Inventory; jump groups in Inventory",
@@ -1175,8 +1176,7 @@ func (m appModel) helpModalOverlay(layout appLayout) string {
" [ / ] Jump to previous / next source group in Inventory",
"",
sectionHeaderStyle.Render("Filters:"),
- " P / G Filter Project-only / Global-only scope",
- " f / F Cycle scope filter / Clear scope filter (All)",
+ " f / F Cycle scope filter (All/Project/Global) / Clear to All",
" a / A Cycle agent filter / Clear agent filter",
" / Initiate text search",
"",