handleCompletionKeys handles keyboard input for the completion screen.
(msg tea.KeyMsg)
| 1539 | |
| 1540 | // handleCompletionKeys handles keyboard input for the completion screen. |
| 1541 | func (a App) handleCompletionKeys(msg tea.KeyMsg) (tea.Model, tea.Cmd) { |
| 1542 | switch msg.String() { |
| 1543 | case "q", "ctrl+c": |
| 1544 | return a.tryQuit() |
| 1545 | |
| 1546 | case "l": |
| 1547 | // Switch to the picker |
| 1548 | a.picker.Refresh() |
| 1549 | a.picker.SetSize(a.width, a.height) |
| 1550 | a.viewMode = ViewPicker |
| 1551 | return a, nil |
| 1552 | |
| 1553 | case "m": |
| 1554 | // Merge the completed PRD's branch |
| 1555 | if a.completionScreen.HasBranch() { |
| 1556 | branch := a.completionScreen.Branch() |
| 1557 | baseDir := a.baseDir |
| 1558 | a.viewMode = ViewDashboard |
| 1559 | return a, func() tea.Msg { |
| 1560 | conflicts, err := git.MergeBranch(baseDir, branch) |
| 1561 | if err != nil { |
| 1562 | return mergeResultMsg{branch: branch, conflicts: conflicts, err: err} |
| 1563 | } |
| 1564 | output := parseMergeSuccessMessage(baseDir, branch) |
| 1565 | return mergeResultMsg{branch: branch, output: output} |
| 1566 | } |
| 1567 | } |
| 1568 | return a, nil |
| 1569 | |
| 1570 | case "c": |
| 1571 | // Clean the PRD's worktree - switch to picker with clean dialog |
| 1572 | if a.completionScreen.HasBranch() { |
| 1573 | prdName := a.completionScreen.PRDName() |
| 1574 | a.picker.Refresh() |
| 1575 | a.picker.SetSize(a.width, a.height) |
| 1576 | // Select the completed PRD in the picker |
| 1577 | for i, entry := range a.picker.entries { |
| 1578 | if entry.Name == prdName { |
| 1579 | a.picker.selectedIndex = i |
| 1580 | break |
| 1581 | } |
| 1582 | } |
| 1583 | if a.picker.CanClean() { |
| 1584 | a.picker.StartCleanConfirmation() |
| 1585 | } |
| 1586 | a.viewMode = ViewPicker |
| 1587 | } |
| 1588 | return a, nil |
| 1589 | |
| 1590 | case "esc": |
| 1591 | a.viewMode = ViewDashboard |
| 1592 | return a, nil |
| 1593 | } |
| 1594 | |
| 1595 | return a, nil |
| 1596 | } |
| 1597 | |
| 1598 | // tickCompletionSpinner returns a tea.Cmd that ticks the completion screen spinner. |
no test coverage detected