feat(FN-1687): merge fusion/fn-1687
This commit is contained in:
@@ -566,10 +566,7 @@ describe("RoadmapsView", () => {
|
||||
expect(screen.getByText("Original Title")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// Click edit button on the suggestion
|
||||
const editBtn = screen.getByTestId("suggestion--title-input");
|
||||
// The edit button doesn't exist yet - just look for the suggestion
|
||||
// This test verifies the suggestion appears
|
||||
// This test verifies the suggestion appears after generation
|
||||
expect(screen.getByText("Original Title")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
@@ -667,6 +667,11 @@ export function useRoadmaps(options?: UseRoadmapsOptions): UseRoadmapsResult {
|
||||
}, []);
|
||||
|
||||
const updateMilestoneSuggestionDraft = useCallback((draftId: string, patch: SuggestionDraftPatch) => {
|
||||
// Update ref first for immediate visibility to acceptAll
|
||||
const currentSuggestions = milestoneSuggestionsRef.current;
|
||||
const updatedSuggestions = currentSuggestions.map((s) => (s.id === draftId ? { ...s, ...patch } : s));
|
||||
milestoneSuggestionsRef.current = updatedSuggestions;
|
||||
// Then update state for re-render
|
||||
setMilestoneSuggestions((prev) =>
|
||||
prev.map((s) => (s.id === draftId ? { ...s, ...patch } : s))
|
||||
);
|
||||
@@ -755,8 +760,7 @@ export function useRoadmaps(options?: UseRoadmapsOptions): UseRoadmapsResult {
|
||||
throw error;
|
||||
}
|
||||
|
||||
// Capture current suggestions (they will be cleared sequentially)
|
||||
// Order is deterministic: follows the current draft display order
|
||||
// Read from ref - it's updated synchronously by updateMilestoneSuggestionDraft
|
||||
const suggestionsToAccept = [...milestoneSuggestionsRef.current];
|
||||
if (suggestionsToAccept.length === 0) {
|
||||
return;
|
||||
@@ -874,6 +878,14 @@ export function useRoadmaps(options?: UseRoadmapsOptions): UseRoadmapsResult {
|
||||
}, []);
|
||||
|
||||
const updateFeatureSuggestionDraft = useCallback((milestoneId: string, draftId: string, patch: SuggestionDraftPatch) => {
|
||||
// Update ref first for immediate visibility to acceptAll
|
||||
const currentSuggestions = featureSuggestionsByMilestoneIdRef.current[milestoneId] || [];
|
||||
const updatedSuggestions = currentSuggestions.map((s) => (s.id === draftId ? { ...s, ...patch } : s));
|
||||
featureSuggestionsByMilestoneIdRef.current = {
|
||||
...featureSuggestionsByMilestoneIdRef.current,
|
||||
[milestoneId]: updatedSuggestions,
|
||||
};
|
||||
// Then update state for re-render
|
||||
setFeatureSuggestionsByMilestoneId((prev) => ({
|
||||
...prev,
|
||||
[milestoneId]: prev[milestoneId]?.map((s) => (s.id === draftId ? { ...s, ...patch } : s)) || [],
|
||||
@@ -956,8 +968,7 @@ export function useRoadmaps(options?: UseRoadmapsOptions): UseRoadmapsResult {
|
||||
milestoneId: string,
|
||||
opts?: { onSuccess?: () => void; onError?: (err: Error) => void }
|
||||
) => {
|
||||
// Capture current suggestions (they will be cleared sequentially)
|
||||
// Order is deterministic: follows the current draft display order
|
||||
// Read from ref - it's updated synchronously by updateFeatureSuggestionDraft
|
||||
const suggestionsToAccept = [...(featureSuggestionsByMilestoneIdRef.current[milestoneId] || [])];
|
||||
if (suggestionsToAccept.length === 0) {
|
||||
return;
|
||||
@@ -971,15 +982,15 @@ export function useRoadmaps(options?: UseRoadmapsOptions): UseRoadmapsResult {
|
||||
throw error;
|
||||
}
|
||||
|
||||
// Capture state for stale-response protection
|
||||
const contextVersionAtStart = projectContextVersionRef.current;
|
||||
|
||||
// Clear suggestions for this milestone immediately (optimistic)
|
||||
setFeatureSuggestionsByMilestoneId((prev) => ({
|
||||
...prev,
|
||||
[milestoneId]: [],
|
||||
}));
|
||||
|
||||
// Capture state for stale-response protection
|
||||
const contextVersionAtStart = projectContextVersionRef.current;
|
||||
|
||||
// Accept sequentially to preserve order
|
||||
for (let i = 0; i < suggestionsToAccept.length; i++) {
|
||||
// Check for stale response
|
||||
|
||||
Reference in New Issue
Block a user