Add snapshot description support (#3094)

Pass the description when creating a snapshot instead of silently
dropping it, and add a PUT endpoint to edit the description later.
An empty description resets to the default text. Also accept an
optional description in the MCP snapshot_create tool.
This commit is contained in:
Guobin Yue authored and GitHub committed 2026-11-16 14:24:20 +01:00
1 parent fe51feec66
commit 8411392233
9 files changed
+148 -11

No files matched your search

+17 -2
View File
@@ -1614,21 +1614,36 @@ class Project:
log.error(f"Cannot write snapshot config '{self._snapshot_conf_path}': {e}")
@open_required
async def snapshot(self, name):
async def snapshot(self, name, description=None):
"""
Snapshot the project
:param name: Name of the snapshot
:param description: Description of the snapshot
"""
if name in [snap.name for snap in self._snapshots.values()]:
raise ControllerError(f"The snapshot name {name} already exists")
snapshot = Snapshot(self, name=name)
snapshot = Snapshot(self, name=name, description=description)
await snapshot.create()
self._snapshots[snapshot.id] = snapshot
self._save_snapshot_config()
return snapshot
@open_required
def update_snapshot(self, snapshot_id, description=None):
"""
Update a snapshot, for example its description
:param snapshot_id: ID of the snapshot
:param description: New description of the snapshot
"""
snapshot = self.get_snapshot(snapshot_id)
snapshot.update(description=description)
self._save_snapshot_config()
return snapshot
@open_required
async def delete_snapshot(self, snapshot_id):
snapshot = self.get_snapshot(snapshot_id)