feat: enhance auto mode service and UI components for branch handling and verification

- Added a new function to retrieve the current branch name in the auto mode service, improving branch management.
- Updated the `getRunningCountForWorktree` method to utilize the current branch name for accurate feature counting.
- Modified UI components to include a toggle for skipping verification in auto mode, enhancing user control.
- Refactored various hooks and components to ensure consistent handling of branch names across the application.
- Introduced a new utility file for string operations, providing common functions for text manipulation.
This commit is contained in:
webdevcody
2026-01-20 13:39:38 -05:00
parent 2ab78dd590
commit 8facdc66a9
10 changed files with 337 additions and 94 deletions

View File

@@ -77,6 +77,7 @@ export function useAutoMode(worktree?: WorktreeInfo) {
getWorktreeKey,
getMaxConcurrencyForWorktree,
setMaxConcurrencyForWorktree,
isPrimaryWorktreeBranch,
} = useAppStore(
useShallow((state) => ({
autoModeByWorktree: state.autoModeByWorktree,
@@ -90,6 +91,7 @@ export function useAutoMode(worktree?: WorktreeInfo) {
getWorktreeKey: state.getWorktreeKey,
getMaxConcurrencyForWorktree: state.getMaxConcurrencyForWorktree,
setMaxConcurrencyForWorktree: state.setMaxConcurrencyForWorktree,
isPrimaryWorktreeBranch: state.isPrimaryWorktreeBranch,
}))
);
@@ -197,9 +199,21 @@ export function useAutoMode(worktree?: WorktreeInfo) {
}
// Extract branchName from event, defaulting to null (main worktree)
const eventBranchName: string | null =
const rawEventBranchName: string | null =
'branchName' in event && event.branchName !== undefined ? event.branchName : null;
// Get projectPath for worktree lookup
const eventProjectPath = 'projectPath' in event ? event.projectPath : currentProject?.path;
// Normalize branchName: convert primary worktree branch to null for consistent key lookup
// This handles cases where the main branch is named something other than 'main' (e.g., 'master', 'develop')
const eventBranchName: string | null =
eventProjectPath &&
rawEventBranchName &&
isPrimaryWorktreeBranch(eventProjectPath, rawEventBranchName)
? null
: rawEventBranchName;
// Skip event if we couldn't determine the project
if (!eventProjectId) {
logger.warn('Could not determine project for event:', event);
@@ -493,6 +507,7 @@ export function useAutoMode(worktree?: WorktreeInfo) {
currentProject?.path,
getMaxConcurrencyForWorktree,
setMaxConcurrencyForWorktree,
isPrimaryWorktreeBranch,
]);
// Start auto mode - calls backend to start the auto loop for this worktree