Skip to content

Commit f65d325

Browse files
committed
fix(devti): prevent duplicate changes in agent state service #352
- Remove existing change with the same afterName before adding a new change - Use canonicalPath to ensure accurate file comparison - Improve deduplication logic for better performance and accuracy
1 parent 62db6b3 commit f65d325

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

core/src/main/kotlin/cc/unitmesh/devti/observer/agent/AgentStateService.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ class AgentStateService(val project: Project) {
5252
}
5353

5454
fun addToChange(patch: TextFilePatch) {
55+
val baseDir = File(project.basePath!!)
56+
val newChangePath = getAbsolutePath(baseDir, patch.afterName).canonicalPath
57+
state.changes.removeIf {
58+
val afterRevision = it.afterRevision
59+
afterRevision != null && File(afterRevision.file.path).canonicalPath == newChangePath
60+
}
61+
5562
val change = createChange(patch)
5663
state.changes.add(change)
5764

0 commit comments

Comments
 (0)