mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 08:33:36 +00:00
feat: enhance auto mode functionality with worktree support
- Updated auto mode handlers to support branch-specific operations, allowing for better management of features across different worktrees. - Introduced normalization of branch names to handle undefined values gracefully. - Enhanced status and response messages to reflect the current worktree context. - Updated the auto mode service to manage state and concurrency settings per worktree, improving user experience and flexibility. - Added UI elements to display current max concurrency for auto mode in both board and mobile views. This update aims to streamline the auto mode experience, making it more intuitive for users working with multiple branches and worktrees.
This commit is contained in:
@@ -30,6 +30,7 @@ import { useAppStore, THEME_STORAGE_KEY } from '@/store/app-store';
|
||||
import { useSetupStore } from '@/store/setup-store';
|
||||
import {
|
||||
DEFAULT_OPENCODE_MODEL,
|
||||
DEFAULT_MAX_CONCURRENCY,
|
||||
getAllOpencodeModelIds,
|
||||
getAllCursorModelIds,
|
||||
migrateCursorModelIds,
|
||||
@@ -194,6 +195,7 @@ export function parseLocalStorageSettings(): Partial<GlobalSettings> | null {
|
||||
keyboardShortcuts: state.keyboardShortcuts as GlobalSettings['keyboardShortcuts'],
|
||||
mcpServers: state.mcpServers as GlobalSettings['mcpServers'],
|
||||
promptCustomization: state.promptCustomization as GlobalSettings['promptCustomization'],
|
||||
eventHooks: state.eventHooks as GlobalSettings['eventHooks'],
|
||||
projects: state.projects as GlobalSettings['projects'],
|
||||
trashedProjects: state.trashedProjects as GlobalSettings['trashedProjects'],
|
||||
currentProjectId: (state.currentProject as { id?: string } | null)?.id ?? null,
|
||||
@@ -635,13 +637,39 @@ export function hydrateStoreFromSettings(settings: GlobalSettings): void {
|
||||
setItem(THEME_STORAGE_KEY, storedTheme);
|
||||
}
|
||||
|
||||
// Restore autoModeByWorktree settings (only maxConcurrency is persisted, runtime state is reset)
|
||||
const restoredAutoModeByWorktree: Record<
|
||||
string,
|
||||
{
|
||||
isRunning: boolean;
|
||||
runningTasks: string[];
|
||||
branchName: string | null;
|
||||
maxConcurrency: number;
|
||||
}
|
||||
> = {};
|
||||
if ((settings as Record<string, unknown>).autoModeByWorktree) {
|
||||
const persistedSettings = (settings as Record<string, unknown>).autoModeByWorktree as Record<
|
||||
string,
|
||||
{ maxConcurrency?: number; branchName?: string | null }
|
||||
>;
|
||||
for (const [key, value] of Object.entries(persistedSettings)) {
|
||||
restoredAutoModeByWorktree[key] = {
|
||||
isRunning: false, // Always start with auto mode off
|
||||
runningTasks: [], // No running tasks on startup
|
||||
branchName: value.branchName ?? null,
|
||||
maxConcurrency: value.maxConcurrency ?? DEFAULT_MAX_CONCURRENCY,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
useAppStore.setState({
|
||||
theme: settings.theme as unknown as import('@/store/app-store').ThemeMode,
|
||||
fontFamilySans: settings.fontFamilySans ?? null,
|
||||
fontFamilyMono: settings.fontFamilyMono ?? null,
|
||||
sidebarOpen: settings.sidebarOpen ?? true,
|
||||
chatHistoryOpen: settings.chatHistoryOpen ?? false,
|
||||
maxConcurrency: settings.maxConcurrency ?? 3,
|
||||
maxConcurrency: settings.maxConcurrency ?? DEFAULT_MAX_CONCURRENCY,
|
||||
autoModeByWorktree: restoredAutoModeByWorktree,
|
||||
defaultSkipTests: settings.defaultSkipTests ?? true,
|
||||
enableDependencyBlocking: settings.enableDependencyBlocking ?? true,
|
||||
skipVerificationInAutoMode: settings.skipVerificationInAutoMode ?? false,
|
||||
@@ -671,6 +699,7 @@ export function hydrateStoreFromSettings(settings: GlobalSettings): void {
|
||||
},
|
||||
mcpServers: settings.mcpServers ?? [],
|
||||
promptCustomization: settings.promptCustomization ?? {},
|
||||
eventHooks: settings.eventHooks ?? [],
|
||||
projects,
|
||||
currentProject,
|
||||
trashedProjects: settings.trashedProjects ?? [],
|
||||
@@ -705,6 +734,19 @@ export function hydrateStoreFromSettings(settings: GlobalSettings): void {
|
||||
function buildSettingsUpdateFromStore(): Record<string, unknown> {
|
||||
const state = useAppStore.getState();
|
||||
const setupState = useSetupStore.getState();
|
||||
|
||||
// Only persist settings (maxConcurrency), not runtime state (isRunning, runningTasks)
|
||||
const persistedAutoModeByWorktree: Record<
|
||||
string,
|
||||
{ maxConcurrency: number; branchName: string | null }
|
||||
> = {};
|
||||
for (const [key, value] of Object.entries(state.autoModeByWorktree)) {
|
||||
persistedAutoModeByWorktree[key] = {
|
||||
maxConcurrency: value.maxConcurrency ?? DEFAULT_MAX_CONCURRENCY,
|
||||
branchName: value.branchName,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
setupComplete: setupState.setupComplete,
|
||||
isFirstRun: setupState.isFirstRun,
|
||||
@@ -713,6 +755,7 @@ function buildSettingsUpdateFromStore(): Record<string, unknown> {
|
||||
sidebarOpen: state.sidebarOpen,
|
||||
chatHistoryOpen: state.chatHistoryOpen,
|
||||
maxConcurrency: state.maxConcurrency,
|
||||
autoModeByWorktree: persistedAutoModeByWorktree,
|
||||
defaultSkipTests: state.defaultSkipTests,
|
||||
enableDependencyBlocking: state.enableDependencyBlocking,
|
||||
skipVerificationInAutoMode: state.skipVerificationInAutoMode,
|
||||
@@ -732,6 +775,7 @@ function buildSettingsUpdateFromStore(): Record<string, unknown> {
|
||||
keyboardShortcuts: state.keyboardShortcuts,
|
||||
mcpServers: state.mcpServers,
|
||||
promptCustomization: state.promptCustomization,
|
||||
eventHooks: state.eventHooks,
|
||||
projects: state.projects,
|
||||
trashedProjects: state.trashedProjects,
|
||||
currentProjectId: state.currentProject?.id ?? null,
|
||||
|
||||
Reference in New Issue
Block a user