Skip to content

Commit ac3fc04

Browse files
ochafikclaude
andcommitted
refactor: persist markers once per batch, not per individual mutation
Move persistMarkers() out of addMarker/updateMarker/removeMarker into processCommands (once after the entire batch). The ontoolresult handler already has its own explicit persistMarkers() call. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 04c8403 commit ac3fc04

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

examples/map-server/src/mcp-app.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,6 @@ function addMarker(
10471047
labelEntity,
10481048
});
10491049
updateCopyButton();
1050-
persistMarkers();
10511050
log.info("Added marker", id, "at", lat, lon, label || "");
10521051
}
10531052

@@ -1114,7 +1113,6 @@ function updateMarker(
11141113
}
11151114

11161115
updateCopyButton();
1117-
persistMarkers();
11181116
log.info("Updated marker", id, updates);
11191117
}
11201118

@@ -1131,7 +1129,6 @@ function removeMarker(cesiumViewer: any, id: string): void {
11311129
if (tracked.labelEntity) cesiumViewer.entities.remove(tracked.labelEntity);
11321130
markerMap.delete(id);
11331131
updateCopyButton();
1134-
persistMarkers();
11351132
log.info("Removed marker", id);
11361133
}
11371134

@@ -1178,6 +1175,8 @@ async function processCommands(commands: MapCommand[]): Promise<void> {
11781175
}
11791176
}
11801177
}
1178+
// Persist once after the entire batch
1179+
persistMarkers();
11811180
}
11821181

11831182
let pollTimer: ReturnType<typeof setInterval> | null = null;

0 commit comments

Comments
 (0)