MCPcopy Create free account
hub / github.com/MiniCodeMonkey/chief / handleSettingsKeys

Method handleSettingsKeys

internal/tui/app.go:1446–1512  ·  view source on GitHub ↗

handleSettingsKeys handles keyboard input for the settings overlay.

(msg tea.KeyMsg)

Source from the content-addressed store, hash-verified

1444
1445// handleSettingsKeys handles keyboard input for the settings overlay.
1446func (a App) handleSettingsKeys(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
1447 // Dismiss GH error on any key
1448 if a.settingsOverlay.HasGHError() {
1449 a.settingsOverlay.DismissGHError()
1450 return a, nil
1451 }
1452
1453 // Handle inline text editing
1454 if a.settingsOverlay.IsEditing() {
1455 switch msg.String() {
1456 case "enter":
1457 a.settingsOverlay.ConfirmEdit()
1458 a.settingsOverlay.ApplyToConfig(a.config)
1459 _ = config.Save(a.baseDir, a.config)
1460 return a, nil
1461 case "esc":
1462 a.settingsOverlay.CancelEdit()
1463 return a, nil
1464 case "backspace":
1465 a.settingsOverlay.DeleteEditChar()
1466 return a, nil
1467 default:
1468 if len(msg.String()) == 1 {
1469 a.settingsOverlay.AddEditChar(rune(msg.String()[0]))
1470 }
1471 return a, nil
1472 }
1473 }
1474
1475 switch msg.String() {
1476 case "esc":
1477 a.viewMode = a.previousViewMode
1478 return a, nil
1479 case "q", "ctrl+c":
1480 return a.tryQuit()
1481 case "up", "k":
1482 a.settingsOverlay.MoveUp()
1483 return a, nil
1484 case "down", "j":
1485 a.settingsOverlay.MoveDown()
1486 return a, nil
1487 case "enter":
1488 item := a.settingsOverlay.GetSelectedItem()
1489 if item == nil {
1490 return a, nil
1491 }
1492 switch item.Type {
1493 case SettingsItemBool:
1494 key, newVal := a.settingsOverlay.ToggleBool()
1495 if key == "onComplete.createPR" && newVal {
1496 // Validate GH CLI asynchronously
1497 return a, func() tea.Msg {
1498 installed, authenticated, err := git.CheckGHCLI()
1499 return settingsGHCheckResultMsg{installed: installed, authenticated: authenticated, err: err}
1500 }
1501 }
1502 a.settingsOverlay.ApplyToConfig(a.config)
1503 _ = config.Save(a.baseDir, a.config)

Callers 1

UpdateMethod · 0.95

Calls 15

tryQuitMethod · 0.95
SaveFunction · 0.92
CheckGHCLIFunction · 0.92
HasGHErrorMethod · 0.80
DismissGHErrorMethod · 0.80
IsEditingMethod · 0.80
ConfirmEditMethod · 0.80
ApplyToConfigMethod · 0.80
CancelEditMethod · 0.80
DeleteEditCharMethod · 0.80
AddEditCharMethod · 0.80
GetSelectedItemMethod · 0.80

Tested by

no test coverage detected