summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/ui/keyhandlers_test.go10
-rw-r--r--internal/ui/table.go18
-rw-r--r--internal/ui/table_test.go14
3 files changed, 41 insertions, 1 deletions
diff --git a/internal/ui/keyhandlers_test.go b/internal/ui/keyhandlers_test.go
index d603aa1..d8a831c 100644
--- a/internal/ui/keyhandlers_test.go
+++ b/internal/ui/keyhandlers_test.go
@@ -35,3 +35,13 @@ func TestSharedKeyBindingsHaveUsableMetadata(t *testing.T) {
}
}
}
+
+func TestAgentFilterHotkeyValidationRejectsSharedKeyBindings(t *testing.T) {
+ for _, binding := range sharedKeyBindings {
+ for _, key := range binding.keys {
+ if err := validateAgentFilterHotkey(key); err == nil {
+ t.Fatalf("shared key binding %q can be set as the agent filter hotkey", key)
+ }
+ }
+ }
+}
diff --git a/internal/ui/table.go b/internal/ui/table.go
index 2a04441..949abbb 100644
--- a/internal/ui/table.go
+++ b/internal/ui/table.go
@@ -1409,12 +1409,28 @@ func validateAgentFilterHotkey(key string) error {
if key == "" {
return nil
}
- if _, ok := reservedAgentHotkeys[key]; ok {
+ if sharedKeyBindingContains(key) || reservedAgentHotkeyContains(key) {
return fmt.Errorf("agent hotkey %q conflicts with an existing command", key)
}
return nil
}
+func sharedKeyBindingContains(key string) bool {
+ for _, binding := range sharedKeyBindings {
+ for _, candidate := range binding.keys {
+ if candidate == key {
+ return true
+ }
+ }
+ }
+ return false
+}
+
+func reservedAgentHotkeyContains(key string) bool {
+ _, ok := reservedAgentHotkeys[key]
+ return ok
+}
+
func normalizeAgentFilterHotkey(key string) string {
key = strings.TrimSpace(key)
if key == "" || len(key) == 1 {
diff --git a/internal/ui/table_test.go b/internal/ui/table_test.go
index c102b82..0920deb 100644
--- a/internal/ui/table_test.go
+++ b/internal/ui/table_test.go
@@ -1603,6 +1603,20 @@ func TestAgentFilterHotkeyRejectsUppercaseNamedKeyCollision(t *testing.T) {
}
}
+func TestAgentFilterHotkeyRejectsShellPromptSharedKeys(t *testing.T) {
+ for _, key := range []string{":", ";"} {
+ t.Run(key, func(t *testing.T) {
+ var m Model
+ if err := m.SetAgentFilterHotkey(key); err == nil {
+ t.Fatalf("expected collision for shell prompt hotkey %q", key)
+ }
+ if got := m.agentFilterHotkeyLabel(); got != "3" {
+ t.Fatalf("colliding shell prompt hotkey changed label: got %q want %q", got, "3")
+ }
+ })
+ }
+}
+
func TestAgentFilterHotkeyCollisionIsRejected(t *testing.T) {
tmp := t.TempDir()
taskPath := filepath.Join(tmp, "task")