mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 08:33:36 +00:00
feat: add pre-enhancement description tracking for feature updates
- Introduced a new parameter `preEnhancementDescription` to capture the original description before enhancements. - Updated the `update` method in `FeatureLoader` to handle the new parameter and maintain a history of original descriptions. - Enhanced UI components to support tracking and restoring pre-enhancement descriptions across various dialogs. - Improved history management in `AddFeatureDialog`, `EditFeatureDialog`, and `FollowUpDialog` to include original text for better user experience. This change enhances the ability to revert to previous descriptions, improving the overall functionality of the feature enhancement process.
This commit is contained in:
@@ -22,7 +22,11 @@ interface EnhanceWithAIProps {
|
||||
/** Callback when text is enhanced */
|
||||
onChange: (enhancedText: string) => void;
|
||||
/** Optional callback to track enhancement in history */
|
||||
onHistoryAdd?: (entry: { mode: EnhancementMode; enhancedText: string }) => void;
|
||||
onHistoryAdd?: (entry: {
|
||||
mode: EnhancementMode;
|
||||
originalText: string;
|
||||
enhancedText: string;
|
||||
}) => void;
|
||||
/** Disable the enhancement feature */
|
||||
disabled?: boolean;
|
||||
/** Additional CSS classes */
|
||||
@@ -69,11 +73,12 @@ export function EnhanceWithAI({
|
||||
);
|
||||
|
||||
if (result?.success && result.enhancedText) {
|
||||
const originalText = value;
|
||||
const enhancedText = result.enhancedText;
|
||||
onChange(enhancedText);
|
||||
|
||||
// Track in history if callback provided
|
||||
onHistoryAdd?.({ mode: enhancementMode, enhancedText });
|
||||
// Track in history if callback provided (includes original for restoration)
|
||||
onHistoryAdd?.({ mode: enhancementMode, originalText, enhancedText });
|
||||
|
||||
toast.success('Enhanced successfully!');
|
||||
} else {
|
||||
|
||||
@@ -45,6 +45,11 @@ export function EnhancementHistoryButton<T extends BaseHistoryEntry>({
|
||||
}: EnhancementHistoryButtonProps<T>) {
|
||||
const [showHistory, setShowHistory] = useState(false);
|
||||
|
||||
// Memoize reversed history to avoid creating new array on every render
|
||||
// NOTE: This hook MUST be called before any early returns to follow Rules of Hooks
|
||||
const reversedHistory = useMemo(() => [...history].reverse(), [history]);
|
||||
|
||||
// Early return AFTER all hooks are called
|
||||
if (history.length === 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -71,9 +76,6 @@ export function EnhancementHistoryButton<T extends BaseHistoryEntry>({
|
||||
});
|
||||
};
|
||||
|
||||
// Memoize reversed history to avoid creating new array on every render
|
||||
const reversedHistory = useMemo(() => [...history].reverse(), [history]);
|
||||
|
||||
return (
|
||||
<Popover open={showHistory} onOpenChange={setShowHistory}>
|
||||
<PopoverTrigger asChild>
|
||||
|
||||
Reference in New Issue
Block a user