Skip to content

AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He

fix(svg-editor): refuse to save staged work onto an SVG changed since staging

hugohe305e627cb3ba0
diff --git a/skills/ppt-master/scripts/svg_editor/server.py b/skills/ppt-master/scripts/svg_editor/server.py
index 1c9b544a..a3483373 100644
--- a/skills/ppt-master/scripts/svg_editor/server.py
+++ b/skills/ppt-master/scripts/svg_editor/server.py
@@ -1138,6 +1138,20 @@ def create_app(
if not svg_file.exists():
failures.append(f'{filename}: Slide not found')
continue
+ # Staged edits and annotations address positional _edit_N ids; if
+ # the SVG changed since staging they would land on other elements.
+ staged_digest = (app.config['DRAFT_BASES'].get(filename) or {}).get('digest')
+ try:
+ changed_on_disk = bool(staged_digest) and _file_digest(svg_file) != staged_digest
+ except OSError as exc:
+ failures.append(f'{filename}: Failed to read SVG: {exc}')
+ continue
+ if changed_on_disk:
+ failures.append(
+ f'{filename}: SVG changed on disk after these changes were staged; '
+ 'reload the slide and redo them'
+ )
+ continue
try:
tree = ET.parse(str(svg_file))
diff --git a/skills/ppt-master/scripts/tests/test_svg_editor_server.py b/skills/ppt-master/scripts/tests/test_svg_editor_server.py
index bfe784b4..f49c3848 100644
--- a/skills/ppt-master/scripts/tests/test_svg_editor_server.py
+++ b/skills/ppt-master/scripts/tests/test_svg_editor_server.py
@@ -148,6 +148,18 @@ class StagingDraftTests(unittest.TestCase):
self.assertFalse(self.draft.exists())
self.assertEqual(client.get('/api/slide/01.svg').get_json()['undo_depth'], 0)
+ def test_save_refuses_staged_work_when_svg_changed_on_disk(self) -> None:
+ client = self._client()
+ self._stage(client)
+ changed = SLIDE_SVG.replace('width="10"', 'width="20"')
+ self.svg_path.write_text(changed, encoding='utf-8')
+
+ response = client.post('/api/save-all')
+ self.assertIn('changed on disk', response.get_json()['error'])
+ self.assertEqual(response.get_json()['files_modified'], [])
+ self.assertEqual(self.svg_path.read_text(encoding='utf-8'), changed)
+ self.assertTrue(self.draft.exists())
+
def test_unreadable_draft_is_set_aside(self) -> None:
self.draft.parent.mkdir()
self.draft.write_text('{not json', encoding='utf-8')