From 260093e61f1689e88b31ecd703313f63beccc1db Mon Sep 17 00:00:00 2001
From: Jinuk Chanthusa <dill.ruzz.official@gmail.com>
Date: Mon, 23 Feb 2026 21:20:09 +0530
Subject: [PATCH 1/2] Annotate ForEach insertAnimation with issue #632 metadata
 (#1)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Motivation
Make the crashing ForEach.insertAnimation test explicitly trackable by linking it to GitHub issue #632 and standardize test metadata.
Improve clarity and consistency in animation test comments and header documentation by correcting small typos.
Description
Annotated ForEachUITests.insertAnimation with @Test(.bug("https://github.com/OpenSwiftUIProject/OpenSwiftUI/issues/632", id: 632)) to attach issue metadata to the test.
Updated the withKnownIssue wrapper for the test to withKnownIssue("#632", isIntermittent: true), added a FIXME noting the snapshot assertion is disabled, and replaced the long AttributeGraph message with Issue.record("AttributeGraph precondition failure in insertAnimation").
Fixed comment typos in animation UI tests by changing seperately → separately and corrected a withKnownIssue identifier from "$690" → "#690" for consistency.
Corrected a misspelling in Sources/OpenSwiftUI_SPI/Shims/kdebug/kdebug_Private.h by changing occured → occurred.
Testing
Ran swift test --filter ForEachUITests.insertAnimation, which failed to build due to a transitive dependency error in the environment (CoreFoundation/CoreFoundation.h not found in OpenRenderBox), therefore the test execution could not complete.
---
 .../Animation/AnimationCompletionUITests.swift       |  2 +-
 .../Animation/Animation/BezierAnimationUITests.swift |  4 ++--
 .../View/DynamicViewContent/ForEachUITests.swift     | 12 +++++++++---
 .../OpenSwiftUI_SPI/Shims/kdebug/kdebug_Private.h    |  2 +-
 4 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/Example/OpenSwiftUIUITests/Animation/Animation/AnimationCompletionUITests.swift b/Example/OpenSwiftUIUITests/Animation/Animation/AnimationCompletionUITests.swift
index 0783a8781..28c20d31f 100644
--- a/Example/OpenSwiftUIUITests/Animation/Animation/AnimationCompletionUITests.swift
+++ b/Example/OpenSwiftUIUITests/Animation/Animation/AnimationCompletionUITests.swift
@@ -45,7 +45,7 @@ struct AnimationCompletionUITests {
                 }
             }
         }
-        // When run seperately, precision: 1.0 works fine
+        // When run separately, precision: 1.0 works fine
         // but in the full suite, it will hit the same issue of #340
         withKnownIssue("#690", isIntermittent: true) {
             openSwiftUIAssertAnimationSnapshot(
diff --git a/Example/OpenSwiftUIUITests/Animation/Animation/BezierAnimationUITests.swift b/Example/OpenSwiftUIUITests/Animation/Animation/BezierAnimationUITests.swift
index 9e5f6b7a2..f4cdd6b69 100644
--- a/Example/OpenSwiftUIUITests/Animation/Animation/BezierAnimationUITests.swift
+++ b/Example/OpenSwiftUIUITests/Animation/Animation/BezierAnimationUITests.swift
@@ -75,9 +75,9 @@ struct BezierAnimationUITests {
                 }
             }
         }
-        // When run seperately, precision: 1.0 works fine
+        // When run separately, precision: 1.0 works fine
         // but in the full suite, it will hit the same issue of #340
-        withKnownIssue("$690", isIntermittent: true) {
+        withKnownIssue("#690", isIntermittent: true) {
             openSwiftUIAssertAnimationSnapshot(
                 of: ContentView(),
             )
diff --git a/Example/OpenSwiftUIUITests/View/DynamicViewContent/ForEachUITests.swift b/Example/OpenSwiftUIUITests/View/DynamicViewContent/ForEachUITests.swift
index 60d096eb0..bd783913a 100644
--- a/Example/OpenSwiftUIUITests/View/DynamicViewContent/ForEachUITests.swift
+++ b/Example/OpenSwiftUIUITests/View/DynamicViewContent/ForEachUITests.swift
@@ -38,7 +38,12 @@ struct ForEachUITests {
         openSwiftUIAssertSnapshot(of: ContentView())
     }
 
-    @Test
+    @Test(
+        .bug(
+            "https://github.com/OpenSwiftUIProject/OpenSwiftUI/issues/632",
+            id: 632
+        )
+    )
     func insertAnimation() {
         struct ContentView: AnimationTestView {
             nonisolated static var model: AnimationTestModel {
@@ -60,9 +65,10 @@ struct ForEachUITests {
                 }
             }
         }
-        withKnownIssue("#632") {
-            Issue.record("AttributeGraph precondition failure: accessing attribute in a different namespace: 36376.")
+        withKnownIssue("#632", isIntermittent: true) {
+            // FIXME: Re-enable after #632 is fixed.
             // openSwiftUIAssertAnimationSnapshot(of: ContentView())
+            Issue.record("AttributeGraph precondition failure in insertAnimation")
         }
     }
 
diff --git a/Sources/OpenSwiftUI_SPI/Shims/kdebug/kdebug_Private.h b/Sources/OpenSwiftUI_SPI/Shims/kdebug/kdebug_Private.h
index 2230b665b..c8177d706 100644
--- a/Sources/OpenSwiftUI_SPI/Shims/kdebug/kdebug_Private.h
+++ b/Sources/OpenSwiftUI_SPI/Shims/kdebug/kdebug_Private.h
@@ -153,7 +153,7 @@ __OSX_AVAILABLE(10.10) __IOS_AVAILABLE(8.2);
 *
 * @return
 * 0 if tracing is disabled or `debugid` is being filtered out of trace.
-* It can also return (int64_t)-1 if an error occured. Otherwise,
+* It can also return (int64_t)-1 if an error occurred. Otherwise,
 * it returns the ID to use to refer to the string in future
 * kdebug_trace(2) calls.
 *

From 360f3e7fa2875f06b7a4c203ac1ac57157f4299b Mon Sep 17 00:00:00 2001
From: Jinuk Chanthusa <dill.ruzz.official@gmail.com>
Date: Mon, 23 Feb 2026 21:38:34 +0530
Subject: [PATCH 2/2] Fix stale ForEach edit bookkeeping for active IDs (#2)

* Fix stale ForEach edit entries for active items

* Stabilize animation snapshots and remove #690 known-issue wrappers
---
 .../Animation/AnimationCompletionUITests.swift       | 12 +++++-------
 .../Animation/Animation/BezierAnimationUITests.swift | 12 +++++-------
 .../Animation/Animation/RepeatAnimationUITests.swift | 12 ++++++------
 .../Graphic/Color/ColorUITests.swift                 |  8 +++++---
 .../View/DynamicViewContent/ForEachUITests.swift     |  4 +---
 .../View/DynamicViewContent/ForEach.swift            |  2 +-
 6 files changed, 23 insertions(+), 27 deletions(-)

diff --git a/Example/OpenSwiftUIUITests/Animation/Animation/AnimationCompletionUITests.swift b/Example/OpenSwiftUIUITests/Animation/Animation/AnimationCompletionUITests.swift
index 28c20d31f..f2c47adf1 100644
--- a/Example/OpenSwiftUIUITests/Animation/Animation/AnimationCompletionUITests.swift
+++ b/Example/OpenSwiftUIUITests/Animation/Animation/AnimationCompletionUITests.swift
@@ -45,12 +45,10 @@ struct AnimationCompletionUITests {
                 }
             }
         }
-        // When run separately, precision: 1.0 works fine
-        // but in the full suite, it will hit the same issue of #340
-        withKnownIssue("#690", isIntermittent: true) {
-            openSwiftUIAssertAnimationSnapshot(
-                of: ContentView()
-            )
-        }
+        openSwiftUIAssertAnimationSnapshot(
+            of: ContentView(),
+            precision: 0.995,
+            perceptualPrecision: 0.995
+        )
     }
 }
diff --git a/Example/OpenSwiftUIUITests/Animation/Animation/BezierAnimationUITests.swift b/Example/OpenSwiftUIUITests/Animation/Animation/BezierAnimationUITests.swift
index f4cdd6b69..51448a7a1 100644
--- a/Example/OpenSwiftUIUITests/Animation/Animation/BezierAnimationUITests.swift
+++ b/Example/OpenSwiftUIUITests/Animation/Animation/BezierAnimationUITests.swift
@@ -75,12 +75,10 @@ struct BezierAnimationUITests {
                 }
             }
         }
-        // When run separately, precision: 1.0 works fine
-        // but in the full suite, it will hit the same issue of #340
-        withKnownIssue("#690", isIntermittent: true) {
-            openSwiftUIAssertAnimationSnapshot(
-                of: ContentView(),
-            )
-        }
+        openSwiftUIAssertAnimationSnapshot(
+            of: ContentView(),
+            precision: 0.995,
+            perceptualPrecision: 0.995
+        )
     }
 }
diff --git a/Example/OpenSwiftUIUITests/Animation/Animation/RepeatAnimationUITests.swift b/Example/OpenSwiftUIUITests/Animation/Animation/RepeatAnimationUITests.swift
index 524ba3ae3..d64420b41 100644
--- a/Example/OpenSwiftUIUITests/Animation/Animation/RepeatAnimationUITests.swift
+++ b/Example/OpenSwiftUIUITests/Animation/Animation/RepeatAnimationUITests.swift
@@ -31,11 +31,11 @@ struct RepeatAnimationUITests {
                     }
             }
         }
-        withKnownIssue("#690", isIntermittent: true) {
-            openSwiftUIAssertAnimationSnapshot(
-                of: ContentView(autoreverses: autoreverses),
-                testName: #function + "\(autoreverses)"
-            )
-        }
+        openSwiftUIAssertAnimationSnapshot(
+            of: ContentView(autoreverses: autoreverses),
+            precision: 0.995,
+            perceptualPrecision: 0.995,
+            testName: #function + "\(autoreverses)"
+        )
     }
 }
diff --git a/Example/OpenSwiftUIUITests/Graphic/Color/ColorUITests.swift b/Example/OpenSwiftUIUITests/Graphic/Color/ColorUITests.swift
index 846bcd72a..f343a1a9e 100644
--- a/Example/OpenSwiftUIUITests/Graphic/Color/ColorUITests.swift
+++ b/Example/OpenSwiftUIUITests/Graphic/Color/ColorUITests.swift
@@ -75,9 +75,11 @@ struct ColorUITests {
                     }
             }
         }
-        withKnownIssue("#690", isIntermittent: true) {
-            openSwiftUIAssertAnimationSnapshot(of: ContentView())
-        }
+        openSwiftUIAssertAnimationSnapshot(
+            of: ContentView(),
+            precision: 0.995,
+            perceptualPrecision: 0.995
+        )
     }
 
     // FIXME
diff --git a/Example/OpenSwiftUIUITests/View/DynamicViewContent/ForEachUITests.swift b/Example/OpenSwiftUIUITests/View/DynamicViewContent/ForEachUITests.swift
index bd783913a..337de7bb6 100644
--- a/Example/OpenSwiftUIUITests/View/DynamicViewContent/ForEachUITests.swift
+++ b/Example/OpenSwiftUIUITests/View/DynamicViewContent/ForEachUITests.swift
@@ -66,9 +66,7 @@ struct ForEachUITests {
             }
         }
         withKnownIssue("#632", isIntermittent: true) {
-            // FIXME: Re-enable after #632 is fixed.
-            // openSwiftUIAssertAnimationSnapshot(of: ContentView())
-            Issue.record("AttributeGraph precondition failure in insertAnimation")
+            openSwiftUIAssertAnimationSnapshot(of: ContentView())
         }
     }
 
diff --git a/Sources/OpenSwiftUICore/View/DynamicViewContent/ForEach.swift b/Sources/OpenSwiftUICore/View/DynamicViewContent/ForEach.swift
index ba15ff28f..d08ebf906 100644
--- a/Sources/OpenSwiftUICore/View/DynamicViewContent/ForEach.swift
+++ b/Sources/OpenSwiftUICore/View/DynamicViewContent/ForEach.swift
@@ -399,7 +399,7 @@ private class ForEachState<Data, ID, Content> where Data: RandomAccessCollection
                         if item.isRemoved {
                             foundActiveItem = false
                         } else {
-                            newEdits = edits
+                            newEdits.removeValue(forKey: id)
                             foundActiveItem = true
                         }
                     } else {
