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

Method handleCleanConfirmationKeys

internal/tui/app.go:1740–1805  ·  view source on GitHub ↗

handleCleanConfirmationKeys handles keyboard input for the clean confirmation dialog.

(msg tea.KeyMsg)

Source from the content-addressed store, hash-verified

1738
1739// handleCleanConfirmationKeys handles keyboard input for the clean confirmation dialog.
1740func (a App) handleCleanConfirmationKeys(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
1741 switch msg.String() {
1742 case "esc":
1743 a.picker.CancelCleanConfirmation()
1744 return a, nil
1745 case "up", "k":
1746 a.picker.CleanConfirmMoveUp()
1747 return a, nil
1748 case "down", "j":
1749 a.picker.CleanConfirmMoveDown()
1750 return a, nil
1751 case "enter":
1752 cc := a.picker.GetCleanConfirmation()
1753 if cc == nil {
1754 return a, nil
1755 }
1756
1757 option := a.picker.GetCleanOption()
1758 if option == CleanOptionCancel {
1759 a.picker.CancelCleanConfirmation()
1760 return a, nil
1761 }
1762
1763 prdName := cc.EntryName
1764 branch := cc.Branch
1765 clearBranch := option == CleanOptionRemoveAll
1766 baseDir := a.baseDir
1767 worktreePath := git.WorktreePathForPRD(baseDir, prdName)
1768
1769 return a, func() tea.Msg {
1770 // Remove the worktree
1771 if err := git.RemoveWorktree(baseDir, worktreePath); err != nil {
1772 return cleanResultMsg{
1773 prdName: prdName,
1774 success: false,
1775 message: fmt.Sprintf("Failed to remove worktree: %s", err.Error()),
1776 }
1777 }
1778
1779 // Delete branch if requested
1780 if clearBranch && branch != "" {
1781 if err := git.DeleteBranch(baseDir, branch); err != nil {
1782 return cleanResultMsg{
1783 prdName: prdName,
1784 success: true,
1785 message: fmt.Sprintf("Removed worktree but failed to delete branch: %s", err.Error()),
1786 clearBranch: false,
1787 }
1788 }
1789 }
1790
1791 msg := fmt.Sprintf("Removed worktree for %s", prdName)
1792 if clearBranch && branch != "" {
1793 msg = fmt.Sprintf("Removed worktree and deleted branch %s", branch)
1794 }
1795 return cleanResultMsg{
1796 prdName: prdName,
1797 success: true,

Callers 1

handlePickerKeysMethod · 0.95

Calls 9

WorktreePathForPRDFunction · 0.92
RemoveWorktreeFunction · 0.92
DeleteBranchFunction · 0.92
CleanConfirmMoveUpMethod · 0.80
CleanConfirmMoveDownMethod · 0.80
GetCleanConfirmationMethod · 0.80
GetCleanOptionMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected