From 312d113fd04bc43996cf97282c34b46ba79c26cd Mon Sep 17 00:00:00 2001 From: G30 <50341825+silentoplayz@users.noreply.github.com> Date: Tue, 20 Oct 2026 12:06:59 -0400 Subject: [PATCH] Merge pull request #32709 from silentoplayz/fix/prompt-save-unchanged-no-version fix: saving a prompt without changes adds no version to its history --- backend/open_webui/models/prompts.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/backend/open_webui/models/prompts.py b/backend/open_webui/models/prompts.py index bfdefccfb6..e4e959dd5f 100644 --- a/backend/open_webui/models/prompts.py +++ b/backend/open_webui/models/prompts.py @@ -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())