mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-31 06:42:03 +00:00
- Migrated settings persistence from localStorage to an API-first approach, ensuring consistency between Electron and web modes. - Introduced `useSettingsSync` hook for automatic synchronization of settings to the server with debouncing. - Enhanced feature update logic to track description changes with a history, allowing for better management of feature descriptions. - Updated various components and services to utilize the new settings structure and description history functionality. - Removed persist middleware from Zustand store, streamlining state management and improving performance.
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
/**
|
|
* POST /update endpoint - Update a feature
|
|
*/
|
|
|
|
import type { Request, Response } from 'express';
|
|
import { FeatureLoader } from '../../../services/feature-loader.js';
|
|
import type { Feature } from '@automaker/types';
|
|
import { getErrorMessage, logError } from '../common.js';
|
|
|
|
export function createUpdateHandler(featureLoader: FeatureLoader) {
|
|
return async (req: Request, res: Response): Promise<void> => {
|
|
try {
|
|
const { projectPath, featureId, updates, descriptionHistorySource, enhancementMode } =
|
|
req.body as {
|
|
projectPath: string;
|
|
featureId: string;
|
|
updates: Partial<Feature>;
|
|
descriptionHistorySource?: 'enhance' | 'edit';
|
|
enhancementMode?: 'improve' | 'technical' | 'simplify' | 'acceptance';
|
|
};
|
|
|
|
if (!projectPath || !featureId || !updates) {
|
|
res.status(400).json({
|
|
success: false,
|
|
error: 'projectPath, featureId, and updates are required',
|
|
});
|
|
return;
|
|
}
|
|
|
|
const updated = await featureLoader.update(
|
|
projectPath,
|
|
featureId,
|
|
updates,
|
|
descriptionHistorySource,
|
|
enhancementMode
|
|
);
|
|
res.json({ success: true, feature: updated });
|
|
} catch (error) {
|
|
logError(error, 'Update feature failed');
|
|
res.status(500).json({ success: false, error: getErrorMessage(error) });
|
|
}
|
|
};
|
|
}
|