mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-10 07:38:04 -05:00
fix(platform): fix library agent version updates and image prepopulation
Backend fixes: - Fix unique constraint violation in update_agent_version_in_library by deleting conflicting records before update - Maintain proper transactional safety for version updates - Preserve original function contract (expects existing agent, throws if not found) Frontend fixes: - Remove redundant hasSubmissionForCurrentVersion logic breaking unpublished changes banner - Fix marketplace update form to prepopulate images (users can keep/remove/add as needed) - Fix duplicate image issue caused by recreating non-deduplicated array in return value - Simplify unpublished changes detection to check current > highest submitted version This resolves the banner not disappearing after marketplace updates and prevents users from having to re-upload images for simple bugfixes.
This commit is contained in:
@@ -504,14 +504,25 @@ async def update_agent_version_in_library(
|
||||
f"Updating agent version in library for user #{user_id}, "
|
||||
f"agent #{agent_graph_id} v{agent_graph_version}"
|
||||
)
|
||||
try:
|
||||
library_agent = await prisma.models.LibraryAgent.prisma().find_first_or_raise(
|
||||
async with transaction() as tx:
|
||||
library_agent = await prisma.models.LibraryAgent.prisma(tx).find_first_or_raise(
|
||||
where={
|
||||
"userId": user_id,
|
||||
"agentGraphId": agent_graph_id,
|
||||
},
|
||||
)
|
||||
lib = await prisma.models.LibraryAgent.prisma().update(
|
||||
|
||||
# Delete any conflicting LibraryAgent for the target version
|
||||
await prisma.models.LibraryAgent.prisma(tx).delete_many(
|
||||
where={
|
||||
"userId": user_id,
|
||||
"agentGraphId": agent_graph_id,
|
||||
"agentGraphVersion": agent_graph_version,
|
||||
"id": {"not": library_agent.id},
|
||||
}
|
||||
)
|
||||
|
||||
lib = await prisma.models.LibraryAgent.prisma(tx).update(
|
||||
where={"id": library_agent.id},
|
||||
data={
|
||||
"AgentGraph": {
|
||||
@@ -525,13 +536,13 @@ async def update_agent_version_in_library(
|
||||
},
|
||||
include={"AgentGraph": True},
|
||||
)
|
||||
if lib is None:
|
||||
raise NotFoundError(f"Library agent {library_agent.id} not found")
|
||||
|
||||
return library_model.LibraryAgent.from_db(lib)
|
||||
except prisma.errors.PrismaError as e:
|
||||
logger.error(f"Database error updating agent version in library: {e}")
|
||||
raise DatabaseError("Failed to update agent version in library") from e
|
||||
if lib is None:
|
||||
raise NotFoundError(
|
||||
f"Failed to update library agent for {agent_graph_id} v{agent_graph_version}"
|
||||
)
|
||||
|
||||
return library_model.LibraryAgent.from_db(lib)
|
||||
|
||||
|
||||
async def update_library_agent(
|
||||
|
||||
@@ -53,14 +53,14 @@ export function useAgentInfoStep({
|
||||
useEffect(() => {
|
||||
if (initialData?.agent_id) {
|
||||
setAgentId(initialData.agent_id);
|
||||
if (!isMarketplaceUpdate) {
|
||||
const initialImages = [
|
||||
...(initialData?.thumbnailSrc ? [initialData.thumbnailSrc] : []),
|
||||
...(initialData.additionalImages || []),
|
||||
];
|
||||
setImages(initialImages);
|
||||
}
|
||||
|
||||
setImages(
|
||||
Array.from(
|
||||
new Set([
|
||||
...(initialData?.thumbnailSrc ? [initialData.thumbnailSrc] : []),
|
||||
...(initialData.additionalImages || []),
|
||||
]),
|
||||
),
|
||||
);
|
||||
form.reset({
|
||||
changesSummary: isMarketplaceUpdate
|
||||
? ""
|
||||
@@ -152,12 +152,7 @@ export function useAgentInfoStep({
|
||||
agentId,
|
||||
images,
|
||||
isSubmitting,
|
||||
initialImages: initialData
|
||||
? [
|
||||
...(initialData?.thumbnailSrc ? [initialData.thumbnailSrc] : []),
|
||||
...(initialData.additionalImages || []),
|
||||
]
|
||||
: [],
|
||||
initialImages: images,
|
||||
initialSelectedImage: initialData?.thumbnailSrc || null,
|
||||
handleImagesChange,
|
||||
handleSubmit: form.handleSubmit(handleFormSubmit),
|
||||
|
||||
Reference in New Issue
Block a user