mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-01 08:13:37 +00:00
refactor: normalize branch name handling and enhance auto mode settings merging
- Updated branch name normalization to align with UI conventions, treating "main" as null for consistency. - Implemented deep merging of `autoModeByWorktree` settings to preserve existing entries during updates. - Enhanced the BoardView component to persist max concurrency settings to the server, ensuring accurate capacity checks. - Added error handling for feature rollback persistence in useBoardActions. These changes improve the reliability and consistency of auto mode settings across the application.
This commit is contained in:
@@ -87,6 +87,7 @@ import { usePipelineConfig } from '@/hooks/queries';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import { queryKeys } from '@/lib/query-keys';
|
||||
import { useAutoModeQueryInvalidation } from '@/hooks/use-query-invalidation';
|
||||
import { useUpdateGlobalSettings } from '@/hooks/mutations/use-settings-mutations';
|
||||
|
||||
// Stable empty array to avoid infinite loop in selector
|
||||
const EMPTY_WORKTREES: ReturnType<ReturnType<typeof useAppStore.getState>['getWorktrees']> = [];
|
||||
@@ -451,6 +452,8 @@ export function BoardView() {
|
||||
const maxConcurrency = autoMode.maxConcurrency;
|
||||
// Get worktree-specific setter
|
||||
const setMaxConcurrencyForWorktree = useAppStore((state) => state.setMaxConcurrencyForWorktree);
|
||||
// Mutation to persist maxConcurrency to server settings
|
||||
const updateGlobalSettings = useUpdateGlobalSettings({ showSuccessToast: false });
|
||||
|
||||
// Get the current branch from the selected worktree (not from store which may be stale)
|
||||
const currentWorktreeBranch = selectedWorktree?.branch ?? null;
|
||||
@@ -1277,6 +1280,15 @@ export function BoardView() {
|
||||
if (currentProject && selectedWorktree) {
|
||||
const branchName = selectedWorktree.isMain ? null : selectedWorktree.branch;
|
||||
setMaxConcurrencyForWorktree(currentProject.id, branchName, newMaxConcurrency);
|
||||
|
||||
// Persist to server settings so capacity checks use the correct value
|
||||
const worktreeKey = `${currentProject.id}::${branchName ?? '__main__'}`;
|
||||
updateGlobalSettings.mutate({
|
||||
autoModeByWorktree: {
|
||||
[worktreeKey]: { maxConcurrency: newMaxConcurrency },
|
||||
},
|
||||
});
|
||||
|
||||
// Also update backend if auto mode is running
|
||||
if (autoMode.isRunning) {
|
||||
// Restart auto mode with new concurrency (backend will handle this)
|
||||
|
||||
@@ -553,6 +553,11 @@ export function useBoardActions({
|
||||
};
|
||||
updateFeature(feature.id, rollbackUpdates);
|
||||
|
||||
// Also persist the rollback so it survives page refresh
|
||||
persistFeatureUpdate(feature.id, rollbackUpdates).catch((persistError) => {
|
||||
logger.error('Failed to persist rollback:', persistError);
|
||||
});
|
||||
|
||||
// If server is offline (connection refused), redirect to login page
|
||||
if (isConnectionError(error)) {
|
||||
handleServerOffline();
|
||||
|
||||
Reference in New Issue
Block a user