mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-03-25 00:33:08 +00:00
Feature: Add PR review comments and resolution, improve AI prompt handling (#790)
* feat: Add PR review comments and resolution endpoints, improve prompt handling * Feature: File Editor (#789) * feat: Add file management feature * feat: Add auto-save functionality to file editor * fix: Replace HardDriveDownload icon with Save icon for consistency * fix: Prevent recursive copy/move and improve shell injection prevention * refactor: Extract editor settings form into separate component * ``` fix: Improve error handling and stabilize async operations - Add error event handlers to GraphQL process spawns to prevent unhandled rejections - Replace execAsync with execFile for safer command execution and better control - Fix timeout cleanup in withTimeout generator to prevent memory leaks - Improve outdated comment detection logic by removing redundant condition - Use resolveModelString for consistent model string handling - Replace || with ?? for proper falsy value handling in dialog initialization - Add comments clarifying branch name resolution logic for local branches with slashes - Add catch handler for project selection to handle async errors gracefully ``` * refactor: Extract PR review comments logic to dedicated service * fix: Improve robustness and UX for PR review and file operations * fix: Consolidate exec utilities and improve type safety * refactor: Replace ScrollArea with div and improve file tree layout
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useState, useCallback, useMemo } from 'react';
|
||||
import { useEffect, useState, useCallback, useMemo, useRef } from 'react';
|
||||
import { createLogger } from '@automaker/utils/logger';
|
||||
import type { PointerEvent as ReactPointerEvent } from 'react';
|
||||
import {
|
||||
@@ -33,7 +33,11 @@ import { getHttpApiClient } from '@/lib/http-api-client';
|
||||
import type { BacklogPlanResult, FeatureStatusWithPipeline } from '@automaker/types';
|
||||
import { pathsEqual } from '@/lib/utils';
|
||||
import { toast } from 'sonner';
|
||||
import { BoardBackgroundModal } from '@/components/dialogs/board-background-modal';
|
||||
import {
|
||||
BoardBackgroundModal,
|
||||
PRCommentResolutionDialog,
|
||||
type PRCommentResolutionPRInfo,
|
||||
} from '@/components/dialogs';
|
||||
import { useShallow } from 'zustand/react/shallow';
|
||||
import { useAutoMode } from '@/hooks/use-auto-mode';
|
||||
import { resolveModelString } from '@automaker/model-resolver';
|
||||
@@ -184,6 +188,9 @@ export function BoardView() {
|
||||
const [showCreatePRDialog, setShowCreatePRDialog] = useState(false);
|
||||
const [showCreateBranchDialog, setShowCreateBranchDialog] = useState(false);
|
||||
const [showMergeRebaseDialog, setShowMergeRebaseDialog] = useState(false);
|
||||
const [showPRCommentDialog, setShowPRCommentDialog] = useState(false);
|
||||
const [prCommentDialogPRInfo, setPRCommentDialogPRInfo] =
|
||||
useState<PRCommentResolutionPRInfo | null>(null);
|
||||
const [selectedWorktreeForAction, setSelectedWorktreeForAction] = useState<WorktreeInfo | null>(
|
||||
null
|
||||
);
|
||||
@@ -429,6 +436,29 @@ export function BoardView() {
|
||||
// This needs to be before useBoardActions so we can pass currentWorktreeBranch
|
||||
const currentWorktreeInfo = currentProject ? getCurrentWorktree(currentProject.path) : null;
|
||||
const currentWorktreePath = currentWorktreeInfo?.path ?? null;
|
||||
|
||||
// Track the previous worktree path to detect worktree switches
|
||||
const prevWorktreePathRef = useRef<string | null | undefined>(undefined);
|
||||
|
||||
// When the active worktree changes, invalidate feature queries to ensure
|
||||
// feature cards (especially their todo lists / planSpec tasks) render fresh data.
|
||||
// Without this, cards that unmount when filtered out and remount when the user
|
||||
// switches back may show stale or missing todo list data until the next polling cycle.
|
||||
useEffect(() => {
|
||||
// Skip the initial mount (prevWorktreePathRef starts as undefined)
|
||||
if (prevWorktreePathRef.current === undefined) {
|
||||
prevWorktreePathRef.current = currentWorktreePath;
|
||||
return;
|
||||
}
|
||||
// Only invalidate when the worktree actually changed
|
||||
if (prevWorktreePathRef.current !== currentWorktreePath && currentProject?.path) {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: queryKeys.features.all(currentProject.path),
|
||||
});
|
||||
}
|
||||
prevWorktreePathRef.current = currentWorktreePath;
|
||||
}, [currentWorktreePath, currentProject?.path, queryClient]);
|
||||
|
||||
const worktreesByProject = useAppStore((s) => s.worktreesByProject);
|
||||
const worktrees = useMemo(
|
||||
() =>
|
||||
@@ -922,26 +952,39 @@ export function BoardView() {
|
||||
[handleAddFeature, handleStartImplementation]
|
||||
);
|
||||
|
||||
// Handler for addressing PR comments - creates a feature and starts it automatically
|
||||
const handleAddressPRComments = useCallback(
|
||||
// Handler for managing PR comments - opens the PR Comment Resolution dialog
|
||||
const handleAddressPRComments = useCallback((worktree: WorktreeInfo, prInfo: PRInfo) => {
|
||||
setPRCommentDialogPRInfo({
|
||||
number: prInfo.number,
|
||||
title: prInfo.title,
|
||||
// Pass the worktree's branch so features are created on the correct worktree
|
||||
headRefName: worktree.branch,
|
||||
});
|
||||
setShowPRCommentDialog(true);
|
||||
}, []);
|
||||
|
||||
// Handler for auto-addressing PR comments - immediately creates and starts a feature task
|
||||
const handleAutoAddressPRComments = useCallback(
|
||||
async (worktree: WorktreeInfo, prInfo: PRInfo) => {
|
||||
// Use a simple prompt that instructs the agent to read and address PR feedback
|
||||
// The agent will fetch the PR comments directly, which is more reliable and up-to-date
|
||||
const prNumber = prInfo.number;
|
||||
const description = `Read the review requests on PR #${prNumber} and address any feedback the best you can.`;
|
||||
if (!prInfo.number) {
|
||||
toast.error('Cannot address PR comments', {
|
||||
description: 'No PR number available for this worktree.',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const featureData = {
|
||||
title: `Address PR #${prNumber} Review Comments`,
|
||||
category: 'PR Review',
|
||||
description,
|
||||
title: `Address PR #${prInfo.number} Review Comments`,
|
||||
category: 'Maintenance',
|
||||
description: `Read the review requests on PR #${prInfo.number} and address any feedback the best you can.`,
|
||||
images: [],
|
||||
imagePaths: [],
|
||||
skipTests: defaultSkipTests,
|
||||
model: 'opus' as const,
|
||||
model: resolveModelString('opus'),
|
||||
thinkingLevel: 'none' as const,
|
||||
branchName: worktree.branch,
|
||||
workMode: 'custom' as const, // Use the worktree's branch
|
||||
priority: 1, // High priority for PR feedback
|
||||
workMode: 'custom' as const,
|
||||
priority: 1,
|
||||
planningMode: 'skip' as const,
|
||||
requirePlanApproval: false,
|
||||
};
|
||||
@@ -988,7 +1031,7 @@ export function BoardView() {
|
||||
images: [],
|
||||
imagePaths: [],
|
||||
skipTests: defaultSkipTests,
|
||||
model: 'opus' as const,
|
||||
model: resolveModelString('opus'),
|
||||
thinkingLevel: 'none' as const,
|
||||
branchName: conflictInfo.targetBranch,
|
||||
workMode: 'custom' as const, // Use the target branch where conflicts need to be resolved
|
||||
@@ -1508,6 +1551,7 @@ export function BoardView() {
|
||||
setShowCreateBranchDialog(true);
|
||||
}}
|
||||
onAddressPRComments={handleAddressPRComments}
|
||||
onAutoAddressPRComments={handleAutoAddressPRComments}
|
||||
onResolveConflicts={handleResolveConflicts}
|
||||
onCreateMergeConflictResolutionFeature={handleCreateMergeConflictResolutionFeature}
|
||||
onBranchSwitchConflict={handleBranchSwitchConflict}
|
||||
@@ -1985,6 +2029,18 @@ export function BoardView() {
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* PR Comment Resolution Dialog */}
|
||||
{prCommentDialogPRInfo && (
|
||||
<PRCommentResolutionDialog
|
||||
open={showPRCommentDialog}
|
||||
onOpenChange={(open) => {
|
||||
setShowPRCommentDialog(open);
|
||||
if (!open) setPRCommentDialogPRInfo(null);
|
||||
}}
|
||||
pr={prCommentDialogPRInfo}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Init Script Indicator - floating overlay for worktree init script status */}
|
||||
{getShowInitScriptIndicator(currentProject.path) && (
|
||||
<InitScriptIndicator projectPath={currentProject.path} />
|
||||
|
||||
Reference in New Issue
Block a user