Merge pull request #32709 from silentoplayz/fix/prompt-save-unchanged-no-version

fix: saving a prompt without changes adds no version to its history
This commit is contained in:
G30 2026-10-20 12:06:59 -04:00 • committed by GitHub
parent 7484c75e16
commit 312d113fd0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -434,11 +434,7 @@ class PromptsTable:
current_access_grants = await self._get_access_grants(prompt.id, db=session)
# Check if content changed to decide on history creation
content_changed = (
prompt.name != form_data.name
or prompt.content != form_data.content
or form_data.access_grants is not None
)
content_changed = prompt.name != form_data.name or prompt.content != form_data.content
# Update prompt fields
prompt.name = form_data.name
@ -447,8 +443,15 @@ class PromptsTable:
prompt.meta = form_data.meta or prompt.meta
prompt.updated_at = int(time.time())
if form_data.access_grants is not None:
previous_access_grants = {
(grant.principal_type, grant.principal_id, grant.permission) for grant in current_access_grants
}
await AccessGrants.set_access_grants('prompt', prompt.id, form_data.access_grants, db=session)
current_access_grants = await self._get_access_grants(prompt.id, db=session)
if previous_access_grants != {
(grant.principal_type, grant.principal_id, grant.permission) for grant in current_access_grants
}:
content_changed = True
await session.commit()
@ -504,7 +507,6 @@ class PromptsTable:
prompt.name != form_data.name
or prompt.command != form_data.command
or prompt.content != form_data.content
or form_data.access_grants is not None
or (form_data.tags is not None and prompt.tags != form_data.tags)
)
@ -521,8 +523,15 @@ class PromptsTable:
prompt.tags = form_data.tags
if form_data.access_grants is not None:
previous_access_grants = {
(grant.principal_type, grant.principal_id, grant.permission) for grant in current_access_grants
}
await AccessGrants.set_access_grants('prompt', prompt.id, form_data.access_grants, db=session)
current_access_grants = await self._get_access_grants(prompt.id, db=session)
if previous_access_grants != {
(grant.principal_type, grant.principal_id, grant.permission) for grant in current_access_grants
}:
content_changed = True
prompt.updated_at = int(time.time())