mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-03-18 10:23:07 +00:00
Bug fixes and stability improvements (#815)
* fix(copilot): correct tool.execution_complete event handling The CopilotProvider was using incorrect event type and data structure for tool execution completion events from the @github/copilot-sdk, causing tool call outputs to be empty. Changes: - Update event type from 'tool.execution_end' to 'tool.execution_complete' - Fix data structure to use nested result.content instead of flat result - Fix error structure to use error.message instead of flat error - Add success field to match SDK event structure - Add tests for empty and missing result handling This aligns with the official @github/copilot-sdk v0.1.16 types defined in session-events.d.ts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * test(copilot): add edge case test for error with code field Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * refactor(copilot): improve error handling and code quality Code review improvements: - Extract magic string '[ERROR]' to TOOL_ERROR_PREFIX constant - Add null-safe error handling with direct error variable assignment - Include error codes in error messages for better debugging - Add JSDoc documentation for tool.execution_complete handler - Update tests to verify error codes are displayed - Add missing tool_use_id assertion in error test These changes improve: - Code maintainability (no magic strings) - Debugging experience (error codes now visible) - Type safety (explicit null checks) - Test coverage (verify error code formatting) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Changes from fix/bug-fixes-1-0 * test(copilot): add edge case test for error with code field Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Changes from fix/bug-fixes-1-0 * fix: Handle detached HEAD state in worktree discovery and recovery * fix: Remove unused isDevServerStarting prop and md: breakpoint classes * fix: Add missing dependency and sanitize persisted cache data * feat: Ensure NODE_ENV is set to test in vitest configs * feat: Configure Playwright to run only E2E tests * fix: Improve PR tracking and dev server lifecycle management * feat: Add settings-based defaults for planning mode, model config, and custom providers. Fixes #816 * feat: Add worktree and branch selector to graph view * fix: Add timeout and error handling for worktree HEAD ref resolution * fix: use absolute icon path and place icon outside asar on Linux The hicolor icon theme index only lists sizes up to 512x512, so an icon installed only at 1024x1024 is invisible to GNOME/KDE's theme resolver, causing both the app launcher and taskbar to show a generic icon. Additionally, BrowserWindow.icon cannot be read by the window manager when the file is inside app.asar. - extraResources: copy logo_larger.png to resources/ (outside asar) so it lands at /opt/Automaker/resources/logo_larger.png on install - linux.desktop.Icon: set to the absolute resources path, bypassing the hicolor theme lookup and its size constraints entirely - icon-manager.ts: on Linux production use process.resourcesPath so BrowserWindow receives a real filesystem path the WM can read directly Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: use linux.desktop.entry for custom desktop Icon field electron-builder v26 rejects arbitrary keys in linux.desktop — the correct schema wraps custom .desktop overrides inside desktop.entry. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: set desktop name on Linux so taskbar uses the correct app icon Without app.setDesktopName(), the window manager cannot associate the running Electron process with automaker.desktop. GNOME/KDE fall back to _NET_WM_ICON which defaults to Electron's own bundled icon. Calling app.setDesktopName('automaker.desktop') before any window is created sets the _GTK_APPLICATION_ID hint and XDG app_id so the WM picks up the desktop entry's Icon for the taskbar. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix: memory and context views mobile friendly (#818) * Changes from fix/memory-and-context-mobile-friendly * fix: Improve file extension detection and add path traversal protection * refactor: Extract file extension utilities and add path traversal guards Code review improvements: - Extract isMarkdownFilename and isImageFilename to shared image-utils.ts - Remove duplicated code from context-view.tsx and memory-view.tsx - Add path traversal guard for context fixture utilities (matching memory) - Add 7 new tests for context fixture path traversal protection - Total 61 tests pass Addresses code review feedback from PR #813 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test: Add e2e tests for profiles crud and board background persistence * Update apps/ui/playwright.config.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix: Add robust test navigation handling and file filtering * fix: Format NODE_OPTIONS configuration on single line * test: Update profiles and board background persistence tests * test: Replace iPhone 13 Pro with Pixel 5 for mobile test consistency * Update apps/ui/src/components/views/context-view.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * chore: Remove test project directory * feat: Filter context files by type and improve mobile menu visibility --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix: Improve test reliability and localhost handling * chore: Use explicit TEST_USE_EXTERNAL_BACKEND env var for server cleanup * feat: Add E2E/CI mock mode for provider factory and auth verification * feat: Add remoteBranch parameter to pull and rebase operations * chore: Enhance E2E testing setup with worker isolation and auth state management - Updated .gitignore to include worker-specific test fixtures. - Modified e2e-tests.yml to implement test sharding for improved CI performance. - Refactored global setup to authenticate once and save session state for reuse across tests. - Introduced worker-isolated fixture paths to prevent conflicts during parallel test execution. - Improved test navigation and loading handling for better reliability. - Updated various test files to utilize new auth state management and fixture paths. * fix: Update Playwright configuration and improve test reliability - Increased the number of workers in Playwright configuration for better parallelism in CI environments. - Enhanced the board background persistence test to ensure dropdown stability by waiting for the list to populate before interaction, improving test reliability. * chore: Simplify E2E test configuration and enhance mock implementations - Updated e2e-tests.yml to run tests in a single shard for streamlined CI execution. - Enhanced unit tests for worktree list handling by introducing a mock for execGitCommand, improving test reliability and coverage. - Refactored setup functions to better manage command mocks for git operations in tests. - Improved error handling in mkdirSafe function to account for undefined stats in certain environments. * refactor: Improve test configurations and enhance error handling - Updated Playwright configuration to clear VITE_SERVER_URL, ensuring the frontend uses the Vite proxy and preventing cookie domain mismatches. - Enhanced MergeRebaseDialog logic to normalize selectedBranch for better handling of various ref formats. - Improved global setup with a more robust backend health check, throwing an error if the backend is not healthy after retries. - Refactored project creation tests to handle file existence checks more reliably. - Added error handling for missing E2E source fixtures to guide setup process. - Enhanced memory navigation to handle sandbox dialog visibility more effectively. * refactor: Enhance Git command execution and improve test configurations - Updated Git command execution to merge environment paths correctly, ensuring proper command execution context. - Refactored the Git initialization process to handle errors more gracefully and ensure user configuration is set before creating the initial commit. - Improved test configurations by updating Playwright test identifiers for better clarity and consistency across different project states. - Enhanced cleanup functions in tests to handle directory removal more robustly, preventing errors during test execution. * fix: Resolve React hooks errors from duplicate instances in dependency tree * style: Format alias configuration for improved readability --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: DhanushSantosh <dhanushsantoshs05@gmail.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
@@ -19,6 +19,7 @@ interface ValidateIssueInput {
|
||||
model?: ModelId;
|
||||
thinkingLevel?: ThinkingLevel;
|
||||
reasoningEffort?: ReasoningEffort;
|
||||
providerId?: string;
|
||||
comments?: GitHubComment[];
|
||||
linkedPRs?: LinkedPRInfo[];
|
||||
}
|
||||
@@ -47,7 +48,8 @@ interface ValidateIssueInput {
|
||||
export function useValidateIssue(projectPath: string) {
|
||||
return useMutation({
|
||||
mutationFn: async (input: ValidateIssueInput) => {
|
||||
const { issue, model, thinkingLevel, reasoningEffort, comments, linkedPRs } = input;
|
||||
const { issue, model, thinkingLevel, reasoningEffort, providerId, comments, linkedPRs } =
|
||||
input;
|
||||
|
||||
const api = getElectronAPI();
|
||||
if (!api.github?.validateIssue) {
|
||||
@@ -71,7 +73,8 @@ export function useValidateIssue(projectPath: string) {
|
||||
validationInput,
|
||||
resolvedModel,
|
||||
thinkingLevel,
|
||||
reasoningEffort
|
||||
reasoningEffort,
|
||||
providerId
|
||||
);
|
||||
|
||||
if (!result.success) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import { getElectronAPI } from '@/lib/electron';
|
||||
import { queryKeys } from '@/lib/query-keys';
|
||||
import { STALE_TIMES } from '@/lib/query-client';
|
||||
import { createSmartPollingInterval, getGlobalEventsRecent } from '@/hooks/use-event-recency';
|
||||
import { isPipelineStatus } from '@automaker/types';
|
||||
import type { Feature } from '@/store/app-store';
|
||||
|
||||
const FEATURES_REFETCH_ON_FOCUS = false;
|
||||
@@ -25,7 +26,7 @@ const FEATURES_CACHE_PREFIX = 'automaker:features-cache:';
|
||||
* Bump this version whenever the Feature shape changes so stale localStorage
|
||||
* entries with incompatible schemas are automatically discarded.
|
||||
*/
|
||||
const FEATURES_CACHE_VERSION = 1;
|
||||
const FEATURES_CACHE_VERSION = 2;
|
||||
|
||||
/** Maximum number of per-project cache entries to keep in localStorage (LRU). */
|
||||
const MAX_FEATURES_CACHE_ENTRIES = 10;
|
||||
@@ -37,13 +38,75 @@ interface PersistedFeaturesCache {
|
||||
features: Feature[];
|
||||
}
|
||||
|
||||
const STATIC_FEATURE_STATUSES: ReadonlySet<string> = new Set([
|
||||
'backlog',
|
||||
'merge_conflict',
|
||||
'ready',
|
||||
'in_progress',
|
||||
'interrupted',
|
||||
'waiting_approval',
|
||||
'verified',
|
||||
'completed',
|
||||
]);
|
||||
|
||||
function isValidFeatureStatus(value: unknown): value is Feature['status'] {
|
||||
return (
|
||||
typeof value === 'string' && (STATIC_FEATURE_STATUSES.has(value) || isPipelineStatus(value))
|
||||
);
|
||||
}
|
||||
|
||||
function sanitizePersistedFeatureEntry(value: unknown): Feature | null {
|
||||
if (typeof value !== 'object' || value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const raw = value as Record<string, unknown>;
|
||||
const id = typeof raw.id === 'string' ? raw.id.trim() : '';
|
||||
if (!id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
...(raw as Feature),
|
||||
id,
|
||||
title: typeof raw.title === 'string' ? raw.title : undefined,
|
||||
titleGenerating: typeof raw.titleGenerating === 'boolean' ? raw.titleGenerating : undefined,
|
||||
category: typeof raw.category === 'string' ? raw.category : '',
|
||||
description: typeof raw.description === 'string' ? raw.description : '',
|
||||
steps: Array.isArray(raw.steps)
|
||||
? raw.steps.filter((step): step is string => typeof step === 'string')
|
||||
: [],
|
||||
status: isValidFeatureStatus(raw.status) ? raw.status : 'backlog',
|
||||
branchName:
|
||||
typeof raw.branchName === 'string' && raw.branchName.trim() ? raw.branchName : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export function sanitizePersistedFeatures(features: unknown): Feature[] {
|
||||
if (!Array.isArray(features)) {
|
||||
return [];
|
||||
}
|
||||
const sanitized: Feature[] = [];
|
||||
for (const feature of features) {
|
||||
const normalized = sanitizePersistedFeatureEntry(feature);
|
||||
if (normalized) {
|
||||
sanitized.push(normalized);
|
||||
}
|
||||
}
|
||||
return sanitized;
|
||||
}
|
||||
|
||||
function readPersistedFeatures(projectPath: string): PersistedFeaturesCache | null {
|
||||
if (typeof window === 'undefined') return null;
|
||||
try {
|
||||
const raw = window.localStorage.getItem(`${FEATURES_CACHE_PREFIX}${projectPath}`);
|
||||
if (!raw) return null;
|
||||
const parsed = JSON.parse(raw) as PersistedFeaturesCache;
|
||||
if (!parsed || !Array.isArray(parsed.features) || typeof parsed.timestamp !== 'number') {
|
||||
const parsed = JSON.parse(raw) as {
|
||||
schemaVersion?: number;
|
||||
timestamp?: number;
|
||||
features?: unknown;
|
||||
};
|
||||
if (!parsed || typeof parsed.timestamp !== 'number') {
|
||||
return null;
|
||||
}
|
||||
// Reject entries written by an older (or newer) schema version
|
||||
@@ -52,7 +115,31 @@ function readPersistedFeatures(projectPath: string): PersistedFeaturesCache | nu
|
||||
window.localStorage.removeItem(`${FEATURES_CACHE_PREFIX}${projectPath}`);
|
||||
return null;
|
||||
}
|
||||
return parsed;
|
||||
const features = sanitizePersistedFeatures(parsed.features);
|
||||
|
||||
// If schema claims valid but nothing survived sanitization, treat as corrupt.
|
||||
if (Array.isArray(parsed.features) && parsed.features.length > 0 && features.length === 0) {
|
||||
window.localStorage.removeItem(`${FEATURES_CACHE_PREFIX}${projectPath}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Migrate partial/corrupt entries in-place so later reads are clean.
|
||||
if (Array.isArray(parsed.features) && features.length !== parsed.features.length) {
|
||||
window.localStorage.setItem(
|
||||
`${FEATURES_CACHE_PREFIX}${projectPath}`,
|
||||
JSON.stringify({
|
||||
schemaVersion: FEATURES_CACHE_VERSION,
|
||||
timestamp: parsed.timestamp,
|
||||
features,
|
||||
} satisfies PersistedFeaturesCache)
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
schemaVersion: FEATURES_CACHE_VERSION,
|
||||
timestamp: parsed.timestamp,
|
||||
features,
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
|
||||
130
apps/ui/src/hooks/use-agent-output-websocket.ts
Normal file
130
apps/ui/src/hooks/use-agent-output-websocket.ts
Normal file
@@ -0,0 +1,130 @@
|
||||
/**
|
||||
* Custom hook for handling WebSocket events in AgentOutputModal
|
||||
* Centralizes WebSocket event logic to reduce duplication
|
||||
*/
|
||||
|
||||
import { useEffect, useRef, useCallback, useState } from 'react';
|
||||
import { getElectronAPI } from '@/lib/electron';
|
||||
import { useAgentOutput } from '@/hooks/queries';
|
||||
import {
|
||||
formatAutoModeEventContent,
|
||||
formatBacklogPlanEventContent,
|
||||
} from '@/components/views/board-view/dialogs/event-content-formatter';
|
||||
import type { AutoModeEvent } from '@/types/electron';
|
||||
import type { BacklogPlanEvent } from '@automaker/types';
|
||||
import { MODAL_CONSTANTS } from '@/components/views/board-view/dialogs/agent-output-modal.constants';
|
||||
|
||||
interface UseAgentOutputWebSocketProps {
|
||||
open: boolean;
|
||||
featureId: string;
|
||||
isBacklogPlan: boolean;
|
||||
projectPath: string;
|
||||
onFeatureComplete?: (passes: boolean) => void;
|
||||
}
|
||||
|
||||
export function useAgentOutputWebSocket({
|
||||
open,
|
||||
featureId,
|
||||
isBacklogPlan,
|
||||
projectPath,
|
||||
onFeatureComplete,
|
||||
}: UseAgentOutputWebSocketProps) {
|
||||
const [streamedContent, setStreamedContent] = useState('');
|
||||
const closeTimeoutRef = useRef<NodeJS.Timeout>();
|
||||
|
||||
// Use React Query for initial output loading
|
||||
const { data: initialOutput = '', isLoading } = useAgentOutput(projectPath, featureId, {
|
||||
enabled: open && !!projectPath,
|
||||
});
|
||||
|
||||
// Combine initial output with streamed content
|
||||
const output = initialOutput + streamedContent;
|
||||
|
||||
// Handle auto mode events
|
||||
const handleAutoModeEvent = useCallback(
|
||||
(event: AutoModeEvent) => {
|
||||
// Filter events for this specific feature only
|
||||
if ('featureId' in event && event.featureId !== featureId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const newContent = formatAutoModeEventContent(event);
|
||||
|
||||
if (newContent) {
|
||||
setStreamedContent((prev) => prev + newContent);
|
||||
}
|
||||
|
||||
// Handle feature completion
|
||||
if (event.type === 'auto_mode_feature_complete' && event.passes && onFeatureComplete) {
|
||||
// Clear any existing timeout first
|
||||
if (closeTimeoutRef.current) {
|
||||
clearTimeout(closeTimeoutRef.current);
|
||||
}
|
||||
|
||||
// Set timeout to close modal after delay
|
||||
closeTimeoutRef.current = setTimeout(() => {
|
||||
onFeatureComplete(true);
|
||||
}, MODAL_CONSTANTS.MODAL_CLOSE_DELAY_MS);
|
||||
}
|
||||
},
|
||||
[featureId, onFeatureComplete]
|
||||
);
|
||||
|
||||
// Handle backlog plan events
|
||||
const handleBacklogPlanEvent = useCallback((event: BacklogPlanEvent) => {
|
||||
const newContent = formatBacklogPlanEventContent(event);
|
||||
|
||||
if (newContent) {
|
||||
setStreamedContent((prev) => prev + newContent);
|
||||
}
|
||||
}, []);
|
||||
|
||||
// Set up WebSocket event listeners
|
||||
useEffect(() => {
|
||||
if (!open) {
|
||||
// Clean up timeout when modal closes
|
||||
if (closeTimeoutRef.current) {
|
||||
clearTimeout(closeTimeoutRef.current);
|
||||
closeTimeoutRef.current = undefined;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const api = getElectronAPI();
|
||||
if (!api) return;
|
||||
|
||||
let unsubscribe: (() => void) | undefined;
|
||||
|
||||
if (isBacklogPlan) {
|
||||
// Handle backlog plan events
|
||||
if (api.backlogPlan) {
|
||||
unsubscribe = api.backlogPlan.onEvent(handleBacklogPlanEvent);
|
||||
}
|
||||
} else {
|
||||
// Handle auto mode events
|
||||
if (api.autoMode) {
|
||||
unsubscribe = api.autoMode.onEvent(handleAutoModeEvent);
|
||||
}
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (closeTimeoutRef.current) {
|
||||
clearTimeout(closeTimeoutRef.current);
|
||||
}
|
||||
unsubscribe?.();
|
||||
};
|
||||
}, [open, featureId, isBacklogPlan, handleAutoModeEvent, handleBacklogPlanEvent]);
|
||||
|
||||
// Reset streamed content when modal opens or featureId changes
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
setStreamedContent('');
|
||||
}
|
||||
}, [open, featureId]);
|
||||
|
||||
return {
|
||||
output,
|
||||
isLoading,
|
||||
streamedContent,
|
||||
};
|
||||
}
|
||||
@@ -11,6 +11,10 @@ import { getGlobalEventsRecent } from '@/hooks/use-event-recency';
|
||||
const logger = createLogger('AutoMode');
|
||||
|
||||
const AUTO_MODE_SESSION_KEY = 'automaker:autoModeRunningByWorktreeKey';
|
||||
// Session key delimiter for parsing stored worktree keys
|
||||
const SESSION_KEY_DELIMITER = '::';
|
||||
// Marker for main worktree in session storage keys
|
||||
const MAIN_WORKTREE_MARKER = '__main__';
|
||||
|
||||
function arraysEqual(a: string[], b: string[]): boolean {
|
||||
if (a.length !== b.length) return false;
|
||||
@@ -25,7 +29,7 @@ const AUTO_MODE_POLLING_INTERVAL = 30000;
|
||||
* @param branchName - The branch name, or null for main worktree
|
||||
*/
|
||||
function getWorktreeSessionKey(projectPath: string, branchName: string | null): string {
|
||||
return `${projectPath}::${branchName ?? '__main__'}`;
|
||||
return `${projectPath}${SESSION_KEY_DELIMITER}${branchName ?? MAIN_WORKTREE_MARKER}`;
|
||||
}
|
||||
|
||||
function readAutoModeSession(): Record<string, boolean> {
|
||||
@@ -84,9 +88,9 @@ export function useAutoMode(worktree?: WorktreeInfo) {
|
||||
setPendingPlanApproval,
|
||||
getWorktreeKey,
|
||||
getMaxConcurrencyForWorktree,
|
||||
setMaxConcurrencyForWorktree,
|
||||
isPrimaryWorktreeBranch,
|
||||
globalMaxConcurrency,
|
||||
addRecentlyCompletedFeature,
|
||||
} = useAppStore(
|
||||
useShallow((state) => ({
|
||||
autoModeByWorktree: state.autoModeByWorktree,
|
||||
@@ -99,9 +103,9 @@ export function useAutoMode(worktree?: WorktreeInfo) {
|
||||
setPendingPlanApproval: state.setPendingPlanApproval,
|
||||
getWorktreeKey: state.getWorktreeKey,
|
||||
getMaxConcurrencyForWorktree: state.getMaxConcurrencyForWorktree,
|
||||
setMaxConcurrencyForWorktree: state.setMaxConcurrencyForWorktree,
|
||||
isPrimaryWorktreeBranch: state.isPrimaryWorktreeBranch,
|
||||
globalMaxConcurrency: state.maxConcurrency,
|
||||
addRecentlyCompletedFeature: state.addRecentlyCompletedFeature,
|
||||
}))
|
||||
);
|
||||
|
||||
@@ -274,6 +278,28 @@ export function useAutoMode(worktree?: WorktreeInfo) {
|
||||
}
|
||||
}, [currentProject, setAutoModeRunning]);
|
||||
|
||||
// Restore auto mode state from session storage on mount.
|
||||
// This ensures that auto mode indicators show up immediately on page load,
|
||||
// before the refreshStatus API call completes. The session storage is
|
||||
// populated whenever auto mode starts/stops, so it provides a reliable
|
||||
// initial state that will be verified/corrected by refreshStatus.
|
||||
useEffect(() => {
|
||||
if (!currentProject) return;
|
||||
|
||||
try {
|
||||
const sessionData = readAutoModeSession();
|
||||
const currentBranchName = branchNameRef.current;
|
||||
const currentKey = getWorktreeSessionKey(currentProject.path, currentBranchName);
|
||||
|
||||
if (sessionData[currentKey] === true) {
|
||||
setAutoModeRunning(currentProject.id, currentBranchName, true);
|
||||
logger.debug(`Restored auto mode state from session storage for key: ${currentKey}`);
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error('Error restoring auto mode state from session storage:', error);
|
||||
}
|
||||
}, [currentProject, setAutoModeRunning]);
|
||||
|
||||
// On mount (and when refreshStatus identity changes, e.g. project switch),
|
||||
// query backend for current auto loop status and sync UI state.
|
||||
// This handles cases where the backend is still running after a page refresh.
|
||||
@@ -445,6 +471,9 @@ export function useAutoMode(worktree?: WorktreeInfo) {
|
||||
// Feature completed - remove from running tasks and UI will reload features on its own
|
||||
if (event.featureId) {
|
||||
logger.info('Feature completed:', event.featureId, 'passes:', event.passes);
|
||||
// Track recently completed to prevent race condition where completed features
|
||||
// briefly appear in backlog due to stale cache data
|
||||
addRecentlyCompletedFeature(event.featureId);
|
||||
removeRunningTask(eventProjectId, eventBranchName, event.featureId);
|
||||
addAutoModeActivity({
|
||||
featureId: event.featureId,
|
||||
@@ -697,6 +726,7 @@ export function useAutoMode(worktree?: WorktreeInfo) {
|
||||
currentProject?.path,
|
||||
getMaxConcurrencyForWorktree,
|
||||
isPrimaryWorktreeBranch,
|
||||
addRecentlyCompletedFeature,
|
||||
]);
|
||||
|
||||
// Start auto mode - calls backend to start the auto loop for this worktree
|
||||
|
||||
@@ -23,8 +23,8 @@ interface UseGuidedPromptsReturn {
|
||||
export function useGuidedPrompts(): UseGuidedPromptsReturn {
|
||||
const { data, isLoading, error, refetch } = useIdeationPrompts();
|
||||
|
||||
const prompts = data?.prompts ?? [];
|
||||
const categories = data?.categories ?? [];
|
||||
const prompts = useMemo(() => data?.prompts ?? [], [data?.prompts]);
|
||||
const categories = useMemo(() => data?.categories ?? [], [data?.categories]);
|
||||
|
||||
const getPromptsByCategory = useCallback(
|
||||
(category: IdeaCategory): IdeationPrompt[] => {
|
||||
|
||||
@@ -204,6 +204,7 @@ export function parseLocalStorageSettings(): Partial<GlobalSettings> | null {
|
||||
projectHistoryIndex: state.projectHistoryIndex as number,
|
||||
lastSelectedSessionByProject:
|
||||
state.lastSelectedSessionByProject as GlobalSettings['lastSelectedSessionByProject'],
|
||||
agentModelBySession: state.agentModelBySession as GlobalSettings['agentModelBySession'],
|
||||
// UI State from standalone localStorage keys or Zustand state
|
||||
worktreePanelCollapsed:
|
||||
worktreePanelCollapsed === 'true' || (state.worktreePanelCollapsed as boolean),
|
||||
@@ -332,6 +333,15 @@ export function mergeSettings(
|
||||
merged.lastSelectedSessionByProject = localSettings.lastSelectedSessionByProject;
|
||||
}
|
||||
|
||||
if (
|
||||
(!serverSettings.agentModelBySession ||
|
||||
Object.keys(serverSettings.agentModelBySession).length === 0) &&
|
||||
localSettings.agentModelBySession &&
|
||||
Object.keys(localSettings.agentModelBySession).length > 0
|
||||
) {
|
||||
merged.agentModelBySession = localSettings.agentModelBySession;
|
||||
}
|
||||
|
||||
// For simple values, use localStorage if server value is default/undefined
|
||||
if (!serverSettings.lastProjectDir && localSettings.lastProjectDir) {
|
||||
merged.lastProjectDir = localSettings.lastProjectDir;
|
||||
@@ -799,6 +809,13 @@ export function hydrateStoreFromSettings(settings: GlobalSettings): void {
|
||||
projectHistory: settings.projectHistory ?? [],
|
||||
projectHistoryIndex: settings.projectHistoryIndex ?? -1,
|
||||
lastSelectedSessionByProject: settings.lastSelectedSessionByProject ?? {},
|
||||
agentModelBySession: settings.agentModelBySession
|
||||
? Object.fromEntries(
|
||||
Object.entries(settings.agentModelBySession as Record<string, unknown>).map(
|
||||
([sessionId, entry]) => [sessionId, migratePhaseModelEntry(entry)]
|
||||
)
|
||||
)
|
||||
: current.agentModelBySession,
|
||||
// Sanitize currentWorktreeByProject: only restore entries where path is null
|
||||
// (main branch). Non-null paths point to worktree directories that may have
|
||||
// been deleted while the app was closed. Restoring a stale path causes the
|
||||
@@ -926,6 +943,7 @@ function buildSettingsUpdateFromStore(): Record<string, unknown> {
|
||||
projectHistory: state.projectHistory,
|
||||
projectHistoryIndex: state.projectHistoryIndex,
|
||||
lastSelectedSessionByProject: state.lastSelectedSessionByProject,
|
||||
agentModelBySession: state.agentModelBySession,
|
||||
currentWorktreeByProject: state.currentWorktreeByProject,
|
||||
worktreePanelCollapsed: state.worktreePanelCollapsed,
|
||||
lastProjectDir: state.lastProjectDir,
|
||||
|
||||
@@ -105,7 +105,7 @@ const SETTINGS_FIELDS_TO_SYNC = [
|
||||
'promptCustomization',
|
||||
'eventHooks',
|
||||
'featureTemplates',
|
||||
'claudeCompatibleProviders',
|
||||
'claudeCompatibleProviders', // Claude-compatible provider configs - must persist to server
|
||||
'claudeApiProfiles',
|
||||
'activeClaudeApiProfileId',
|
||||
'projects',
|
||||
@@ -450,6 +450,7 @@ export function useSettingsSync(): SettingsSyncState {
|
||||
}
|
||||
|
||||
initializeSync();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- state.loaded is intentionally excluded to prevent infinite loop
|
||||
}, [authChecked, isAuthenticated, settingsLoaded]);
|
||||
|
||||
// Subscribe to store changes and sync to server
|
||||
@@ -823,6 +824,9 @@ export async function refreshSettingsFromServer(): Promise<boolean> {
|
||||
editorAutoSaveDelay: serverSettings.editorAutoSaveDelay ?? 1000,
|
||||
defaultTerminalId: serverSettings.defaultTerminalId ?? null,
|
||||
promptCustomization: serverSettings.promptCustomization ?? {},
|
||||
// Claude-compatible providers - must be loaded from server for persistence
|
||||
claudeCompatibleProviders: serverSettings.claudeCompatibleProviders ?? [],
|
||||
// Deprecated Claude API profiles (kept for migration)
|
||||
claudeApiProfiles: serverSettings.claudeApiProfiles ?? [],
|
||||
activeClaudeApiProfileId: serverSettings.activeClaudeApiProfileId ?? null,
|
||||
projects: serverSettings.projects,
|
||||
|
||||
@@ -59,7 +59,6 @@ export function useTestRunners(worktreePath?: string) {
|
||||
// Get store state and actions
|
||||
const {
|
||||
sessions,
|
||||
activeSessionByWorktree,
|
||||
isLoading,
|
||||
error,
|
||||
startSession,
|
||||
@@ -75,7 +74,6 @@ export function useTestRunners(worktreePath?: string) {
|
||||
} = useTestRunnersStore(
|
||||
useShallow((state) => ({
|
||||
sessions: state.sessions,
|
||||
activeSessionByWorktree: state.activeSessionByWorktree,
|
||||
isLoading: state.isLoading,
|
||||
error: state.error,
|
||||
startSession: state.startSession,
|
||||
@@ -95,12 +93,12 @@ export function useTestRunners(worktreePath?: string) {
|
||||
const activeSession = useMemo(() => {
|
||||
if (!worktreePath) return null;
|
||||
return getActiveSession(worktreePath);
|
||||
}, [worktreePath, getActiveSession, activeSessionByWorktree]);
|
||||
}, [worktreePath, getActiveSession]);
|
||||
|
||||
const isRunning = useMemo(() => {
|
||||
if (!worktreePath) return false;
|
||||
return isWorktreeRunning(worktreePath);
|
||||
}, [worktreePath, isWorktreeRunning, activeSessionByWorktree, sessions]);
|
||||
}, [worktreePath, isWorktreeRunning]);
|
||||
|
||||
// Get all sessions for the current worktree
|
||||
const worktreeSessions = useMemo(() => {
|
||||
|
||||
Reference in New Issue
Block a user