AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(platform): store submission validation and marketplace improvements (#11706)
Zamil Majdy36fb1ea00413
diff --git a/autogpt_platform/backend/backend/api/features/library/model.py b/autogpt_platform/backend/backend/api/features/library/model.pyindex c20f82afae..56fad7bfd3 100644--- a/autogpt_platform/backend/backend/api/features/library/model.py+++ b/autogpt_platform/backend/backend/api/features/library/model.py@@ -48,6 +48,7 @@ class LibraryAgent(pydantic.BaseModel):id: strgraph_id: strgraph_version: int+ owner_user_id: str # ID of user who owns/created this agent graphimage_url: str | None@@ -163,6 +164,7 @@ class LibraryAgent(pydantic.BaseModel):id=agent.id,graph_id=agent.agentGraphId,graph_version=agent.agentGraphVersion,+ owner_user_id=agent.userId,image_url=agent.imageUrl,creator_name=creator_name,creator_image_url=creator_image_url,diff --git a/autogpt_platform/backend/backend/api/features/library/routes_test.py b/autogpt_platform/backend/backend/api/features/library/routes_test.pyindex ad28b5b6bd..0f05240a7f 100644--- a/autogpt_platform/backend/backend/api/features/library/routes_test.py+++ b/autogpt_platform/backend/backend/api/features/library/routes_test.py@@ -42,6 +42,7 @@ async def test_get_library_agents_success(id="test-agent-1",graph_id="test-agent-1",graph_version=1,+ owner_user_id=test_user_id,name="Test Agent 1",description="Test Description 1",image_url=None,@@ -64,6 +65,7 @@ async def test_get_library_agents_success(id="test-agent-2",graph_id="test-agent-2",graph_version=1,+ owner_user_id=test_user_id,name="Test Agent 2",description="Test Description 2",image_url=None,@@ -138,6 +140,7 @@ async def test_get_favorite_library_agents_success(id="test-agent-1",graph_id="test-agent-1",graph_version=1,+ owner_user_id=test_user_id,name="Favorite Agent 1",description="Test Favorite Description 1",image_url=None,@@ -205,6 +208,7 @@ def test_add_agent_to_library_success(id="test-library-agent-id",graph_id="test-agent-1",graph_version=1,+ owner_user_id=test_user_id,name="Test Agent 1",description="Test Description 1",image_url=None,diff --git a/autogpt_platform/backend/backend/api/features/store/db.py b/autogpt_platform/backend/backend/api/features/store/db.pyindex 8e5a39df89..18db6f43ce 100644--- a/autogpt_platform/backend/backend/api/features/store/db.py+++ b/autogpt_platform/backend/backend/api/features/store/db.py@@ -614,6 +614,7 @@ async def get_store_submissions(submission_models = []for sub in submissions:submission_model = store_model.StoreSubmission(+ listing_id=sub.listing_id,agent_id=sub.agent_id,agent_version=sub.agent_version,name=sub.name,@@ -667,35 +668,48 @@ async def delete_store_submission(submission_id: str,) -> bool:"""- Delete a store listing submission as the submitting user.+ Delete a store submission version as the submitting user.Args:user_id: ID of the authenticated user- submission_id: ID of the submission to be deleted+ submission_id: StoreListingVersion ID to deleteReturns:- bool: True if the submission was successfully deleted, False otherwise+ bool: True if successfully deleted"""- logger.debug(f"Deleting store submission {submission_id} for user {user_id}")-try:- # Verify the submission belongs to this user- submission = await prisma.models.StoreListing.prisma().find_first(- where={"agentGraphId": submission_id, "owningUserId": user_id}+ # Find the submission version with ownership check+ version = await prisma.models.StoreListingVersion.prisma().find_first(+ where={"id": submission_id}, include={"StoreListing": True})- if not submission:- logger.warning(f"Submission not found for user {user_id}: {submission_id}")- raise store_exceptions.SubmissionNotFoundError(- f"Submission not found for this user. User ID: {user_id}, Submission ID: {submission_id}"+ if (+ not version+ or not version.StoreListing+ or version.StoreListing.owningUserId != user_id+ ):+ raise store_exceptions.SubmissionNotFoundError("Submission not found")++ # Prevent deletion of approved submissions+ if version.submissionStatus == prisma.enums.SubmissionStatus.APPROVED:+ raise store_exceptions.InvalidOperationError(+ "Cannot delete approved submissions")- # Delete the submission- await prisma.models.StoreListing.prisma().delete(where={"id": submission.id})+ # Delete the version+ await prisma.models.StoreListingVersion.prisma().delete(+ where={"id": version.id}+ )- logger.debug(- f"Successfully deleted submission {submission_id} for user {user_id}"+ # Clean up empty listing if this was the last version+ remaining = await prisma.models.StoreListingVersion.prisma().count(+ where={"storeListingId": version.storeListingId})+ if remaining == 0:+ await prisma.models.StoreListing.prisma().delete(+ where={"id": version.storeListingId}+ )+return Trueexcept Exception as e:@@ -759,9 +773,15 @@ async def create_store_submission(logger.warning(f"Agent not found for user {user_id}: {agent_id} v{agent_version}")- raise store_exceptions.AgentNotFoundError(- f"Agent not found for this user. User ID: {user_id}, Agent ID: {agent_id}, Version: {agent_version}"- )+ # Provide more user-friendly error message when agent_id is empty+ if not agent_id or agent_id.strip() == "":+ raise store_exceptions.AgentNotFoundError(+ "No agent selected. Please select an agent before submitting to the store."+ )+ else:+ raise store_exceptions.AgentNotFoundError(+ f"Agent not found for this user. User ID: {user_id}, Agent ID: {agent_id}, Version: {agent_version}"+ )# Check if listing already exists for this agentexisting_listing = await prisma.models.StoreListing.prisma().find_first(@@ -833,6 +853,7 @@ async def create_store_submission(logger.debug(f"Created store listing for agent {agent_id}")# Return submission detailsreturn store_model.StoreSubmission(+ listing_id=listing.id,agent_id=agent_id,agent_version=agent_version,name=name,@@ -944,81 +965,56 @@ async def edit_store_submission(# Currently we are not allowing user to update the agent associated with a submission# If we allow it in future, then we need a check here to verify the agent belongs to this user.- # Check if we can edit this submission- if current_version.submissionStatus == prisma.enums.SubmissionStatus.REJECTED:+ # Only allow editing of PENDING submissions+ if current_version.submissionStatus != prisma.enums.SubmissionStatus.PENDING:raise store_exceptions.InvalidOperationError(- "Cannot edit a rejected submission"+ f"Cannot edit a {current_version.submissionStatus.value.lower()} submission. Only pending submissions can be edited.")- # For APPROVED submissions, we need to create a new version- if current_version.submissionStatus == prisma.enums.SubmissionStatus.APPROVED:- # Create a new version for the existing listing- return await create_store_version(- user_id=user_id,- agent_id=current_version.agentGraphId,- agent_version=current_version.agentGraphVersion,- store_listing_id=current_version.storeListingId,+ # For PENDING submissions, we can update the existing version+ # Update the existing version+ updated_version = await prisma.models.StoreListingVersion.prisma().update(+ where={"id": store_listing_version_id},+ data=prisma.types.StoreListingVersionUpdateInput(name=name,- video_url=video_url,- agent_output_demo_url=agent_output_demo_url,- image_urls=image_urls,+ videoUrl=video_url,+ agentOutputDemoUrl=agent_output_demo_url,+ imageUrls=image_urls,description=description,- sub_heading=sub_heading,categories=categories,- changes_summary=changes_summary,- recommended_schedule_cron=recommended_schedule_cron,+ subHeading=sub_heading,+ changesSummary=changes_summary,+ recommendedScheduleCron=recommended_schedule_cron,instructions=instructions,- )-- # For PENDING submissions, we can update the existing version- elif current_version.submissionStatus == prisma.enums.SubmissionStatus.PENDING:- # Update the existing version- updated_version = await prisma.models.StoreListingVersion.prisma().update(- where={"id": store_listing_version_id},- data=prisma.types.StoreListingVersionUpdateInput(- name=name,- videoUrl=video_url,- agentOutputDemoUrl=agent_output_demo_url,- imageUrls=image_urls,- description=description,- categories=categories,- subHeading=sub_heading,- changesSummary=changes_summary,- recommendedScheduleCron=recommended_schedule_cron,- instructions=instructions,- ),- )-- logger.debug(- f"Updated existing version {store_listing_version_id} for agent {current_version.agentGraphId}"- )+ ),+ )- if not updated_version:- raise DatabaseError("Failed to update store listing version")- return store_model.StoreSubmission(- agent_id=current_version.agentGraphId,- agent_version=current_version.agentGraphVersion,- name=name,- sub_heading=sub_heading,- slug=current_version.StoreListing.slug,- description=description,- instructions=instructions,- image_urls=image_urls,- date_submitted=updated_version.submittedAt or updated_version.createdAt,- status=updated_version.submissionStatus,- runs=0,- rating=0.0,- store_listing_version_id=updated_version.id,- changes_summary=changes_summary,- video_url=video_url,- categories=categories,- version=updated_version.version,- )+ logger.debug(+ f"Updated existing version {store_listing_version_id} for agent {current_version.agentGraphId}"+ )- else:- raise store_exceptions.InvalidOperationError(- f"Cannot edit submission with status: {current_version.submissionStatus}"- )+ if not updated_version:+ raise DatabaseError("Failed to update store listing version")+ return store_model.StoreSubmission(+ listing_id=current_version.StoreListing.id,+ agent_id=current_version.agentGraphId,+ agent_version=current_version.agentGraphVersion,+ name=name,+ sub_heading=sub_heading,+ slug=current_version.StoreListing.slug,+ description=description,+ instructions=instructions,+ image_urls=image_urls,+ date_submitted=updated_version.submittedAt or updated_version.createdAt,+ status=updated_version.submissionStatus,+ runs=0,+ rating=0.0,+ store_listing_version_id=updated_version.id,+ changes_summary=changes_summary,+ video_url=video_url,+ categories=categories,+ version=updated_version.version,+ )except (store_exceptions.SubmissionNotFoundError,@@ -1097,38 +1093,78 @@ async def create_store_version(f"Agent not found for this user. User ID: {user_id}, Agent ID: {agent_id}, Version: {agent_version}")- # Get the latest version number- latest_version = listing.Versions[0] if listing.Versions else None+ # Check if there's already a PENDING submission for this agent (any version)+ existing_pending_submission = (+ await prisma.models.StoreListingVersion.prisma().find_first(+ where=prisma.types.StoreListingVersionWhereInput(+ storeListingId=store_listing_id,+ agentGraphId=agent_id,+ submissionStatus=prisma.enums.SubmissionStatus.PENDING,+ isDeleted=False,+ )+ )+ )- next_version = (latest_version.version + 1) if latest_version else 1+ # Handle existing pending submission and create new one atomically+ async with transaction() as tx:+ # Get the latest version number first+ latest_listing = await prisma.models.StoreListing.prisma(tx).find_first(+ where=prisma.types.StoreListingWhereInput(+ id=store_listing_id, owningUserId=user_id+ ),+ include={"Versions": {"order_by": {"version": "desc"}, "take": 1}},+ )- # Create a new version for the existing listing- new_version = await prisma.models.StoreListingVersion.prisma().create(- data=prisma.types.StoreListingVersionCreateInput(- version=next_version,- agentGraphId=agent_id,- agentGraphVersion=agent_version,- name=name,- videoUrl=video_url,- agentOutputDemoUrl=agent_output_demo_url,- imageUrls=image_urls,- description=description,- instructions=instructions,- categories=categories,- subHeading=sub_heading,- submissionStatus=prisma.enums.SubmissionStatus.PENDING,- submittedAt=datetime.now(),- changesSummary=changes_summary,- recommendedScheduleCron=recommended_schedule_cron,- storeListingId=store_listing_id,+ if not latest_listing:+ raise store_exceptions.ListingNotFoundError(+ f"Store listing not found. User ID: {user_id}, Listing ID: {store_listing_id}"+ )++ latest_version = (+ latest_listing.Versions[0] if latest_listing.Versions else None+ )+ next_version = (latest_version.version + 1) if latest_version else 1++ # If there's an existing pending submission, delete it atomically before creating new one+ if existing_pending_submission:+ logger.info(+ f"Found existing PENDING submission for agent {agent_id} (was v{existing_pending_submission.agentGraphVersion}, now v{agent_version}), replacing existing submission instead of creating duplicate"+ )+ await prisma.models.StoreListingVersion.prisma(tx).delete(+ where={"id": existing_pending_submission.id}+ )+ logger.debug(+ f"Deleted existing pending submission {existing_pending_submission.id}"+ )++ # Create a new version for the existing listing+ new_version = await prisma.models.StoreListingVersion.prisma(tx).create(+ data=prisma.types.StoreListingVersionCreateInput(+ version=next_version,+ agentGraphId=agent_id,+ agentGraphVersion=agent_version,+ name=name,+ videoUrl=video_url,+ agentOutputDemoUrl=agent_output_demo_url,+ imageUrls=image_urls,+ description=description,+ instructions=instructions,+ categories=categories,+ subHeading=sub_heading,+ submissionStatus=prisma.enums.SubmissionStatus.PENDING,+ submittedAt=datetime.now(),+ changesSummary=changes_summary,+ recommendedScheduleCron=recommended_schedule_cron,+ storeListingId=store_listing_id,+ ))- )logger.debug(f"Created new version for listing {store_listing_id} of agent {agent_id}")# Return submission detailsreturn store_model.StoreSubmission(+ listing_id=listing.id,agent_id=agent_id,agent_version=agent_version,name=name,@@ -1708,15 +1744,12 @@ async def review_store_submission(# Convert to Pydantic model for consistencyreturn store_model.StoreSubmission(+ listing_id=(submission.StoreListing.id if submission.StoreListing else ""),agent_id=submission.agentGraphId,agent_version=submission.agentGraphVersion,name=submission.name,sub_heading=submission.subHeading,- slug=(- submission.StoreListing.slug- if hasattr(submission, "storeListing") and submission.StoreListing- else ""- ),+ slug=(submission.StoreListing.slug if submission.StoreListing else ""),description=submission.description,instructions=submission.instructions,image_urls=submission.imageUrls or [],@@ -1845,6 +1878,7 @@ async def get_admin_listings_with_versions(# If we have versions, turn them into StoreSubmission modelsfor version in listing.Versions or []:version_model = store_model.StoreSubmission(+ listing_id=listing.id,agent_id=version.agentGraphId,agent_version=version.agentGraphVersion,name=version.name,diff --git a/autogpt_platform/backend/backend/api/features/store/model.py b/autogpt_platform/backend/backend/api/features/store/model.pyindex 972898b296..077135217a 100644--- a/autogpt_platform/backend/backend/api/features/store/model.py+++ b/autogpt_platform/backend/backend/api/features/store/model.py@@ -110,6 +110,7 @@ class Profile(pydantic.BaseModel):class StoreSubmission(pydantic.BaseModel):+ listing_id: stragent_id: stragent_version: intname: str@@ -164,8 +165,12 @@ class StoreListingsWithVersionsResponse(pydantic.BaseModel):class StoreSubmissionRequest(pydantic.BaseModel):- agent_id: str- agent_version: int+ agent_id: str = pydantic.Field(+ ..., min_length=1, description="Agent ID cannot be empty"+ )+ agent_version: int = pydantic.Field(+ ..., gt=0, description="Agent version must be greater than 0"+ )slug: strname: strsub_heading: strdiff --git a/autogpt_platform/backend/backend/api/features/store/model_test.py b/autogpt_platform/backend/backend/api/features/store/model_test.pyindex a37966601b..fd09a0cf77 100644--- a/autogpt_platform/backend/backend/api/features/store/model_test.py+++ b/autogpt_platform/backend/backend/api/features/store/model_test.py@@ -138,6 +138,7 @@ def test_creator_details():def test_store_submission():submission = store_model.StoreSubmission(+ listing_id="listing123",agent_id="agent123",agent_version=1,sub_heading="Test subheading",@@ -159,6 +160,7 @@ def test_store_submissions_response():response = store_model.StoreSubmissionsResponse(submissions=[store_model.StoreSubmission(+ listing_id="listing123",agent_id="agent123",agent_version=1,sub_heading="Test subheading",diff --git a/autogpt_platform/backend/backend/api/features/store/routes_test.py b/autogpt_platform/backend/backend/api/features/store/routes_test.pyindex 7fdc0b9ebb..36431c20ec 100644--- a/autogpt_platform/backend/backend/api/features/store/routes_test.py+++ b/autogpt_platform/backend/backend/api/features/store/routes_test.py@@ -521,6 +521,7 @@ def test_get_submissions_success(mocked_value = store_model.StoreSubmissionsResponse(submissions=[store_model.StoreSubmission(+ listing_id="test-listing-id",name="Test Agent",description="Test agent description",image_urls=["test.jpg"],diff --git a/autogpt_platform/backend/snapshots/lib_agts_search b/autogpt_platform/backend/snapshots/lib_agts_searchindex d1feb7d16d..c8e3cc73a6 100644--- a/autogpt_platform/backend/snapshots/lib_agts_search+++ b/autogpt_platform/backend/snapshots/lib_agts_search@@ -4,6 +4,7 @@"id": "test-agent-1","graph_id": "test-agent-1","graph_version": 1,+ "owner_user_id": "3e53486c-cf57-477e-ba2a-cb02dc828e1a","image_url": null,"creator_name": "Test Creator","creator_image_url": "",@@ -41,6 +42,7 @@"id": "test-agent-2","graph_id": "test-agent-2","graph_version": 1,+ "owner_user_id": "3e53486c-cf57-477e-ba2a-cb02dc828e1a","image_url": null,"creator_name": "Test Creator","creator_image_url": "",diff --git a/autogpt_platform/backend/snapshots/sub_success b/autogpt_platform/backend/snapshots/sub_successindex 13e2ec570d..268d577745 100644--- a/autogpt_platform/backend/snapshots/sub_success+++ b/autogpt_platform/backend/snapshots/sub_success@@ -1,6 +1,7 @@{"submissions": [{+ "listing_id": "test-listing-id","agent_id": "test-agent-id","agent_version": 1,"name": "Test Agent",diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/hooks/useMarketplaceUpdate.ts b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/hooks/useMarketplaceUpdate.tsindex 4ae146e514..fc32ba4b8d 100644--- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/hooks/useMarketplaceUpdate.ts+++ b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/hooks/useMarketplaceUpdate.ts@@ -40,15 +40,17 @@ export function useMarketplaceUpdate({ agent }: UseMarketplaceUpdateProps) {},);- // Get user's submissions to check for pending submissions- const { data: submissionsData } = useGetV2ListMySubmissions(- { page: 1, page_size: 50 }, // Get enough to cover recent submissions- {- query: {- enabled: !!user?.id, // Only fetch if user is authenticated+ // Get user's submissions - only fetch if user is the creator+ const { data: submissionsData, isLoading: isSubmissionsLoading } =+ useGetV2ListMySubmissions(+ { page: 1, page_size: 50 },+ {+ query: {+ // Only fetch if user is the creator+ enabled: !!(user?.id && agent?.owner_user_id === user.id),+ },},- },- );+ );const updateToLatestMutation = usePatchV2UpdateLibraryAgent({mutation: {@@ -78,29 +80,17 @@ export function useMarketplaceUpdate({ agent }: UseMarketplaceUpdateProps) {// Check if marketplace has a newer version than user's current versionconst marketplaceUpdateInfo = React.useMemo(() => {const storeAgent = okData(storeAgentData) as any;- if (!agent || !storeAgent) {++ if (!agent || isSubmissionsLoading) {return {hasUpdate: false,latestVersion: undefined,isUserCreator: false,+ hasPublishUpdate: false,};}- // Get the latest version from the marketplace- // agentGraphVersions array contains graph version numbers as strings, get the highest one- const latestMarketplaceVersion =- storeAgent.agentGraphVersions?.length > 0- ? Math.max(- ...storeAgent.agentGraphVersions.map((v: string) =>- parseInt(v, 10),- ),- )- : undefined;-- // Determine if the user is the creator of this agent- // Compare current user ID with the marketplace listing creator ID- const isUserCreator =- user?.id && agent.marketplace_listing?.creator.id === user.id;+ const isUserCreator = agent?.owner_user_id === user?.id;// Check if there's a pending submission for this specific agent versionconst submissionsResponse = okData(submissionsData) as any;@@ -113,13 +103,36 @@ export function useMarketplaceUpdate({ agent }: UseMarketplaceUpdateProps) {submission.status === "PENDING",);- // If user is creator and their version is newer than marketplace, show publish update banner- // BUT only if there's no pending submission for this version+ if (!storeAgent) {+ return {+ hasUpdate: false,+ latestVersion: undefined,+ isUserCreator,+ hasPublishUpdate:+ isUserCreator && !hasPendingSubmissionForCurrentVersion,+ };+ }++ // Get the latest version from the marketplace+ // agentGraphVersions array contains graph version numbers as strings, get the highest one+ const latestMarketplaceVersion =+ storeAgent.agentGraphVersions?.length > 0+ ? Math.max(+ ...storeAgent.agentGraphVersions.map((v: string) =>+ parseInt(v, 10),+ ),+ )+ : undefined;++ // Show publish update button if:+ // 1. User is the creator+ // 2. No pending submission for current version+ // 3. Either: agent not published yet OR local version is newer than marketplaceconst hasPublishUpdate =isUserCreator &&!hasPendingSubmissionForCurrentVersion &&- latestMarketplaceVersion !== undefined &&- agent.graph_version > latestMarketplaceVersion;+ (latestMarketplaceVersion === undefined || // Not published yet+ agent.graph_version > latestMarketplaceVersion); // Or local version is newer// If marketplace version is newer than user's version, show update banner// This applies to both creators and non-creators@@ -133,7 +146,7 @@ export function useMarketplaceUpdate({ agent }: UseMarketplaceUpdateProps) {isUserCreator,hasPublishUpdate,};- }, [agent, storeAgentData, user, submissionsData]);+ }, [agent, storeAgentData, user, submissionsData, isSubmissionsLoading]);const handlePublishUpdate = () => {setModalOpen(true);diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/components/AgentInfo/AgentInfo.tsx b/autogpt_platform/frontend/src/app/(platform)/marketplace/components/AgentInfo/AgentInfo.tsxindex a7a690c67e..8098af7405 100644--- a/autogpt_platform/frontend/src/app/(platform)/marketplace/components/AgentInfo/AgentInfo.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/marketplace/components/AgentInfo/AgentInfo.tsx@@ -12,6 +12,7 @@ import type { GetV2GetSpecificAgentParams } from "@/app/api/__generated__/modelsimport { useAgentInfo } from "./useAgentInfo";import { useGetV2GetSpecificAgent } from "@/app/api/__generated__/endpoints/store/store";import { Text } from "@/components/atoms/Text/Text";+import { formatTimeAgo } from "@/lib/utils/time";import * as React from "react";interface AgentInfoProps {@@ -258,23 +259,29 @@ export const AgentInfo = ({</div></div>- {/* Changelog */}+ {/* Version history */}<div className="flex w-full flex-col gap-1.5 sm:gap-2">- <div className="decoration-skip-ink-none mb-1.5 text-base font-medium leading-6 text-neutral-800 dark:text-neutral-200 sm:mb-2">- Changelog+ <div className="decoration-skip-ink-none text-base font-medium leading-6 text-neutral-800 dark:text-neutral-200">+ Version history+ </div>+ <div className="decoration-skip-ink-none text-sm font-normal leading-6 text-neutral-600 underline-offset-[from-font] dark:text-neutral-400">+ Last updated {formatTimeAgo(lastUpdated)}</div>- <div className="decoration-skip-ink-none text-base font-normal leading-6 text-neutral-600 underline-offset-[from-font] dark:text-neutral-400">- Last updated {lastUpdated}+ <div className="decoration-skip-ink-none text-xs text-neutral-600 dark:text-neutral-400 sm:text-sm">+ Version {version}.0</div>{/* Version List */}{agentVersions.length > 0 ? (- <div className="mt-4">+ <div className="mt-3">+ <div className="decoration-skip-ink-none mb-1.5 text-base font-medium leading-6 text-neutral-900 dark:text-neutral-200 sm:mb-2">+ Changelog+ </div>{agentVersions.map(renderVersionItem)}{hasMoreVersions && (<buttononClick={() => setVisibleVersionCount((prev) => prev + 3)}- className="mt-2 flex items-center gap-1 text-sm font-medium text-neutral-900 hover:text-neutral-700 dark:text-neutral-100 dark:hover:text-neutral-300"+ className="mt-2 flex items-center gap-1 text-sm font-medium text-neutral-700 hover:text-neutral-700 dark:text-neutral-100 dark:hover:text-neutral-300"><svgwidth="16"@@ -297,7 +304,7 @@ export const AgentInfo = ({</div>) : (<div className="text-xs text-neutral-600 dark:text-neutral-400 sm:text-sm">- Version {version}+ Version {version}.0</div>)}</div>diff --git a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/dashboard/components/AgentTableCard/AgentTableCard.tsx b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/dashboard/components/AgentTableCard/AgentTableCard.tsxindex a8d5d23912..0e1a6ac095 100644--- a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/dashboard/components/AgentTableCard/AgentTableCard.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/dashboard/components/AgentTableCard/AgentTableCard.tsx@@ -18,6 +18,7 @@ export interface AgentTableCardProps {runs: number;rating: number;id: number;+ listing_id?: string;onViewSubmission: (submission: StoreSubmission) => void;}@@ -32,10 +33,12 @@ export const AgentTableCard = ({status,runs,rating,+ listing_id,onViewSubmission,}: AgentTableCardProps) => {const onView = () => {onViewSubmission({+ listing_id: listing_id || "",agent_id,agent_version,slug: "",@@ -62,9 +65,14 @@ export const AgentTableCard = ({/></div><div className="flex-1">- <h3 className="text-[15px] font-medium text-neutral-800 dark:text-neutral-200">- {agentName}- </h3>+ <div className="flex items-center gap-2">+ <h3 className="text-[15px] font-medium text-neutral-800 dark:text-neutral-200">+ {agentName}+ </h3>+ <span className="text-[13px] text-neutral-500 dark:text-neutral-400">+ v{agent_version}+ </span>+ </div><p className="line-clamp-2 text-sm text-neutral-600 dark:text-neutral-400">{description}</p>diff --git a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/dashboard/components/AgentTableRow/AgentTableRow.tsx b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/dashboard/components/AgentTableRow/AgentTableRow.tsxindex 5b85ade1ae..917b872df1 100644--- a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/dashboard/components/AgentTableRow/AgentTableRow.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/dashboard/components/AgentTableRow/AgentTableRow.tsx@@ -9,11 +9,11 @@ import { useAgentTableRow } from "./useAgentTableRow";import { StoreSubmission } from "@/app/api/__generated__/models/storeSubmission";import {DotsThreeVerticalIcon,- Eye,+ EyeIcon,ImageBroken,- Star,- Trash,- PencilSimple,+ StarIcon,+ TrashIcon,+ PencilIcon,} from "@phosphor-icons/react/dist/ssr";import { SubmissionStatus } from "@/app/api/__generated__/models/submissionStatus";import { StoreSubmissionEditRequest } from "@/app/api/__generated__/models/storeSubmissionEditRequest";@@ -34,6 +34,7 @@ export interface AgentTableRowProps {categories?: string[];store_listing_version_id?: string;changes_summary?: string;+ listing_id?: string;onViewSubmission: (submission: StoreSubmission) => void;onDeleteSubmission: (submission_id: string) => void;onEditSubmission: (@@ -60,6 +61,7 @@ export const AgentTableRow = ({categories,store_listing_version_id,changes_summary,+ listing_id,onViewSubmission,onDeleteSubmission,onEditSubmission,@@ -83,11 +85,10 @@ export const AgentTableRow = ({categories,store_listing_version_id,changes_summary,+ listing_id,});- // Determine if we should show Edit or View button- const canEdit =- status === SubmissionStatus.APPROVED || status === SubmissionStatus.PENDING;+ const canModify = status === SubmissionStatus.PENDING;return (<div@@ -114,13 +115,22 @@ export const AgentTableRow = ({</div>)}<div className="flex flex-col">- <Text- variant="h3"- className="line-clamp-1 text-ellipsis text-neutral-800 dark:text-neutral-200"- size="large-medium"- >- {agentName}- </Text>+ <div className="flex items-center gap-2">+ <Text+ variant="h3"+ className="line-clamp-1 text-ellipsis text-neutral-800 dark:text-neutral-200"+ size="large-medium"+ >+ {agentName}+ </Text>+ <Text+ variant="body"+ size="small"+ className="text-neutral-500 dark:text-neutral-400"+ >+ v{agent_version}+ </Text>+ </div><Textvariant="body"className="line-clamp-1 text-ellipsis text-neutral-600 dark:text-neutral-400"@@ -150,7 +160,7 @@ export const AgentTableRow = ({{rating ? (<div className="flex items-center justify-end gap-1"><span className="text-sm font-medium">{rating.toFixed(1)}</span>- <Star weight="fill" className="h-2 w-2" />+ <StarIcon weight="fill" className="h-2 w-2" /></div>) : (<span className="text-sm text-neutral-600 dark:text-neutral-400">@@ -166,12 +176,12 @@ export const AgentTableRow = ({<DotsThreeVerticalIcon className="h-5 w-5 text-neutral-800" /></DropdownMenu.Trigger><DropdownMenu.Content className="z-10 rounded-xl border bg-white p-1 shadow-md dark:bg-gray-800">- {canEdit ? (+ {canModify ? (<DropdownMenu.ItemonSelect={handleEdit}className="flex cursor-pointer items-center rounded-md px-3 py-2 hover:bg-gray-100 dark:hover:bg-gray-700">- <PencilSimple className="mr-2 h-4 w-4 dark:text-gray-100" />+ <PencilIcon className="mr-2 h-4 w-4 dark:text-gray-100" /><span className="dark:text-gray-100">Edit</span></DropdownMenu.Item>) : (@@ -179,18 +189,22 @@ export const AgentTableRow = ({onSelect={handleView}className="flex cursor-pointer items-center rounded-md px-3 py-2 hover:bg-gray-100 dark:hover:bg-gray-700">- <Eye className="mr-2 h-4 w-4 dark:text-gray-100" />+ <EyeIcon className="mr-2 h-4 w-4 dark:text-gray-100" /><span className="dark:text-gray-100">View</span></DropdownMenu.Item>)}- <DropdownMenu.Separator className="my-1 h-px bg-gray-300 dark:bg-gray-600" />- <DropdownMenu.Item- onSelect={handleDelete}- className="flex cursor-pointer items-center rounded-md px-3 py-2 text-red-500 hover:bg-gray-100 dark:hover:bg-gray-700"- >- <Trash className="mr-2 h-4 w-4 text-red-500 dark:text-red-400" />- <span className="dark:text-red-400">Delete</span>- </DropdownMenu.Item>+ {canModify && (+ <>+ <DropdownMenu.Separator className="my-1 h-px bg-gray-300 dark:bg-gray-600" />+ <DropdownMenu.Item+ onSelect={handleDelete}+ className="flex cursor-pointer items-center rounded-md px-3 py-2 text-red-500 hover:bg-gray-100 dark:hover:bg-gray-700"+ >+ <TrashIcon className="mr-2 h-4 w-4 text-red-500 dark:text-red-400" />+ <span className="dark:text-red-400">Delete</span>+ </DropdownMenu.Item>+ </>+ )}</DropdownMenu.Content></DropdownMenu.Root></div>diff --git a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/dashboard/components/AgentTableRow/useAgentTableRow.ts b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/dashboard/components/AgentTableRow/useAgentTableRow.tsindex 14fbac4336..7879446d27 100644--- a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/dashboard/components/AgentTableRow/useAgentTableRow.ts+++ b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/dashboard/components/AgentTableRow/useAgentTableRow.ts@@ -26,6 +26,7 @@ interface useAgentTableRowProps {categories?: string[];store_listing_version_id?: string;changes_summary?: string;+ listing_id?: string;}export const useAgentTableRow = ({@@ -46,9 +47,11 @@ export const useAgentTableRow = ({categories,store_listing_version_id,changes_summary,+ listing_id,}: useAgentTableRowProps) => {const handleView = () => {onViewSubmission({+ listing_id: listing_id || "",agent_id,agent_version,slug: "",@@ -81,7 +84,14 @@ export const useAgentTableRow = ({};const handleDelete = () => {- onDeleteSubmission(agent_id);+ // Backend only accepts StoreListingVersion IDs for deletion+ if (!store_listing_version_id) {+ console.error(+ "Cannot delete submission: store_listing_version_id is required",+ );+ return;+ }+ onDeleteSubmission(store_listing_version_id);};return { handleView, handleDelete, handleEdit };diff --git a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/dashboard/components/MainDashboardPage/MainDashboardPage.tsx b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/dashboard/components/MainDashboardPage/MainDashboardPage.tsxindex e53244db77..9bfc536d8b 100644--- a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/dashboard/components/MainDashboardPage/MainDashboardPage.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/dashboard/components/MainDashboardPage/MainDashboardPage.tsx@@ -99,6 +99,7 @@ export const MainDashboardPage = () => {store_listing_version_id:submission.store_listing_version_id || undefined,changes_summary: submission.changes_summary || undefined,+ listing_id: submission.listing_id,}))}onViewSubmission={onViewSubmission}onDeleteSubmission={onDeleteSubmission}diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.jsonindex ea3bbcc5d8..249d67e749 100644--- a/autogpt_platform/frontend/src/app/api/openapi.json+++ b/autogpt_platform/frontend/src/app/api/openapi.json@@ -7665,6 +7665,7 @@"id": { "type": "string", "title": "Id" },"graph_id": { "type": "string", "title": "Graph Id" },"graph_version": { "type": "integer", "title": "Graph Version" },+ "owner_user_id": { "type": "string", "title": "Owner User Id" },"image_url": {"anyOf": [{ "type": "string" }, { "type": "null" }],"title": "Image Url"@@ -7747,6 +7748,7 @@"id","graph_id","graph_version",+ "owner_user_id","image_url","creator_name","creator_image_url",@@ -9686,6 +9688,7 @@},"StoreSubmission": {"properties": {+ "listing_id": { "type": "string", "title": "Listing Id" },"agent_id": { "type": "string", "title": "Agent Id" },"agent_version": { "type": "integer", "title": "Agent Version" },"name": { "type": "string", "title": "Name" },@@ -9757,6 +9760,7 @@},"type": "object","required": [+ "listing_id","agent_id","agent_version","name",@@ -9819,8 +9823,18 @@},"StoreSubmissionRequest": {"properties": {- "agent_id": { "type": "string", "title": "Agent Id" },- "agent_version": { "type": "integer", "title": "Agent Version" },+ "agent_id": {+ "type": "string",+ "minLength": 1,+ "title": "Agent Id",+ "description": "Agent ID cannot be empty"+ },+ "agent_version": {+ "type": "integer",+ "exclusiveMinimum": 0.0,+ "title": "Agent Version",+ "description": "Agent version must be greater than 0"+ },"slug": { "type": "string", "title": "Slug" },"name": { "type": "string", "title": "Name" },"sub_heading": { "type": "string", "title": "Sub Heading" },diff --git a/autogpt_platform/frontend/src/components/contextual/EditAgentModal/EditAgentModal.tsx b/autogpt_platform/frontend/src/components/contextual/EditAgentModal/EditAgentModal.tsxindex 501650a36b..243b478f49 100644--- a/autogpt_platform/frontend/src/components/contextual/EditAgentModal/EditAgentModal.tsx+++ b/autogpt_platform/frontend/src/components/contextual/EditAgentModal/EditAgentModal.tsx@@ -27,6 +27,7 @@ export function EditAgentModal({return (<Dialog+ title="Edit Agent"styling={{maxWidth: "45rem",}}diff --git a/autogpt_platform/frontend/src/components/contextual/EditAgentModal/components/EditAgentForm.tsx b/autogpt_platform/frontend/src/components/contextual/EditAgentModal/components/EditAgentForm.tsxindex 7f04f91a92..6a6e7401a3 100644--- a/autogpt_platform/frontend/src/components/contextual/EditAgentModal/components/EditAgentForm.tsx+++ b/autogpt_platform/frontend/src/components/contextual/EditAgentModal/components/EditAgentForm.tsx@@ -8,7 +8,6 @@ import { Form, FormField } from "@/components/__legacy__/ui/form";import { StoreSubmission } from "@/app/api/__generated__/models/storeSubmission";import { ThumbnailImages } from "../../PublishAgentModal/components/AgentInfoStep/components/ThumbnailImages";import { StoreSubmissionEditRequest } from "@/app/api/__generated__/models/storeSubmissionEditRequest";-import { StepHeader } from "../../PublishAgentModal/components/StepHeader";import { useEditAgentForm } from "./useEditAgentForm";interface EditAgentFormProps {@@ -31,12 +30,10 @@ export function EditAgentForm({isSubmitting,handleFormSubmit,handleImagesChange,- } = useEditAgentForm({ submission, onSuccess });+ } = useEditAgentForm({ submission, onSuccess, onClose });return (<div className="mx-auto flex w-full flex-col rounded-3xl">- <StepHeader title="Edit Agent" description="Update your agent details" />-<Form {...form}><formonSubmit={form.handleSubmit(handleFormSubmit)}@@ -75,7 +72,7 @@ export function EditAgentForm({<ThumbnailImagesagentId={submission.agent_id}onImagesChange={handleImagesChange}- initialImages={submission.image_urls || []}+ initialImages={Array.from(new Set(submission.image_urls || []))}initialSelectedImage={submission.image_urls?.[0] || null}errorMessage={form.formState.errors.root?.message}/>diff --git a/autogpt_platform/frontend/src/components/contextual/EditAgentModal/components/useEditAgentForm.ts b/autogpt_platform/frontend/src/components/contextual/EditAgentModal/components/useEditAgentForm.tsindex 8de7c43659..88ec698f8a 100644--- a/autogpt_platform/frontend/src/components/contextual/EditAgentModal/components/useEditAgentForm.ts+++ b/autogpt_platform/frontend/src/components/contextual/EditAgentModal/components/useEditAgentForm.ts@@ -19,11 +19,13 @@ interface useEditAgentFormProps {agent_id: string;};onSuccess: (submission: StoreSubmission) => void;+ onClose: () => void;}export const useEditAgentForm = ({submission,onSuccess,+ onClose,}: useEditAgentFormProps) => {const editAgentSchema = z.object({title: z@@ -54,19 +56,11 @@ export const useEditAgentForm = ({type EditAgentFormData = z.infer<typeof editAgentSchema>;const [images, setImages] = React.useState<string[]>(- submission.image_urls || [],+ Array.from(new Set(submission.image_urls || [])), // Remove duplicates);const [isSubmitting, setIsSubmitting] = React.useState(false);- const { mutateAsync: editSubmission } = usePutV2EditStoreSubmission({- mutation: {- onSuccess: () => {- queryClient.invalidateQueries({- queryKey: getGetV2ListMySubmissionsQueryKey(),- });- },- },- });+ const { mutateAsync: editSubmission } = usePutV2EditStoreSubmission();const queryClient = useQueryClient();const { toast } = useToast();@@ -132,7 +126,20 @@ export const useEditAgentForm = ({// Extract the StoreSubmission from the responseif (response.status === 200 && response.data) {+ toast({+ title: "Agent Updated",+ description: "Your agent submission has been updated successfully.",+ duration: 3000,+ variant: "default",+ });++ queryClient.invalidateQueries({+ queryKey: getGetV2ListMySubmissionsQueryKey(),+ });++ // Call onSuccess and explicitly close the modalonSuccess(response.data);+ onClose();} else {throw new Error("Failed to update submission");}diff --git a/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/components/AgentInfoStep/useAgentInfoStep.ts b/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/components/AgentInfoStep/useAgentInfoStep.tsindex f3dcfa1f21..d46357846e 100644--- a/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/components/AgentInfoStep/useAgentInfoStep.ts+++ b/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/components/AgentInfoStep/useAgentInfoStep.ts@@ -1,10 +1,8 @@import { useEffect, useCallback, useState } from "react";import { useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";-import { useQueryClient } from "@tanstack/react-query";import { useToast } from "@/components/molecules/Toast/use-toast";import { useBackendAPI } from "@/lib/autogpt-server-api/context";-import { getGetV2ListMySubmissionsQueryKey } from "@/app/api/__generated__/endpoints/store/store";import * as Sentry from "@sentry/nextjs";import {PublishAgentFormData,@@ -33,7 +31,6 @@ export function useAgentInfoStep({const [images, setImages] = useState<string[]>([]);const [isSubmitting, setIsSubmitting] = useState(false);- const queryClient = useQueryClient();const { toast } = useToast();const api = useBackendAPI();@@ -54,7 +51,7 @@ export function useAgentInfoStep({});useEffect(() => {- if (initialData) {+ if (initialData?.agent_id) {setAgentId(initialData.agent_id);const initialImages = [...(initialData?.thumbnailSrc ? [initialData.thumbnailSrc] : []),@@ -78,6 +75,13 @@ export function useAgentInfoStep({}}, [initialData, form]);+ // Ensure agentId is set from selectedAgentId if initialData doesn't have it+ useEffect(() => {+ if (selectedAgentId && !agentId) {+ setAgentId(selectedAgentId);+ }+ }, [selectedAgentId, agentId]);+const handleImagesChange = useCallback((newImages: string[]) => {setImages(newImages);}, []);@@ -92,6 +96,16 @@ export function useAgentInfoStep({return;}+ // Validate that an agent is selected before submission+ if (!selectedAgentId || !selectedAgentVersion) {+ toast({+ title: "Agent Selection Required",+ description: "Please select an agent before submitting to the store.",+ variant: "destructive",+ });+ return;+ }+const categories = data.category ? [data.category] : [];const filteredCategories = categories.filter(Boolean);@@ -106,18 +120,14 @@ export function useAgentInfoStep({image_urls: images,video_url: data.youtubeLink || "",agent_output_demo_url: data.agentOutputDemo || "",- agent_id: selectedAgentId || "",- agent_version: selectedAgentVersion || 0,+ agent_id: selectedAgentId,+ agent_version: selectedAgentVersion,slug: (data.slug || "").replace(/\s+/g, "-"),categories: filteredCategories,recommended_schedule_cron: data.recommendedScheduleCron || null,changes_summary: data.changesSummary || null,} as any);- await queryClient.invalidateQueries({- queryKey: getGetV2ListMySubmissionsQueryKey(),- });-onSuccess(response);} catch (error) {Sentry.captureException(error);diff --git a/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/usePublishAgentModal.ts b/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/usePublishAgentModal.tsindex 0f8a819c6e..69bbb6c866 100644--- a/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/usePublishAgentModal.ts+++ b/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/usePublishAgentModal.ts@@ -6,9 +6,11 @@ import { emptyModalState } from "./helpers";import {useGetV2GetMyAgents,useGetV2ListMySubmissions,+ getGetV2ListMySubmissionsQueryKey,} from "@/app/api/__generated__/endpoints/store/store";import { okData } from "@/app/api/helpers";import type { MyAgent } from "@/app/api/__generated__/models/myAgent";+import { useQueryClient } from "@tanstack/react-query";const defaultTargetState: PublishState = {isOpen: false,@@ -65,6 +67,7 @@ export function usePublishAgentModal({>(preSelectedAgentVersion || null);const router = useRouter();+ const queryClient = useQueryClient();// Fetch agent data for pre-populating form when agent is pre-selectedconst { data: myAgents } = useGetV2GetMyAgents();@@ -77,14 +80,18 @@ export function usePublishAgentModal({}}, [targetState]);- // Reset internal state when modal opens+ // Reset internal state when modal opens (only on initial open, not on every targetState change)+ const [hasOpened, setHasOpened] = useState(false);useEffect(() => {if (!targetState) return;- if (targetState.isOpen) {+ if (targetState.isOpen && !hasOpened) {setSelectedAgent(null);setSelectedAgentId(preSelectedAgentId || null);setSelectedAgentVersion(preSelectedAgentVersion || null);setInitialData(emptyModalState);+ setHasOpened(true);+ } else if (!targetState.isOpen && hasOpened) {+ setHasOpened(false);}}, [targetState, preSelectedAgentId, preSelectedAgentVersion]);@@ -172,6 +179,11 @@ export function usePublishAgentModal({setSelectedAgentVersion(null);setInitialData(emptyModalState);+ // Invalidate submissions query to refresh the data after modal closes+ queryClient.invalidateQueries({+ queryKey: getGetV2ListMySubmissionsQueryKey(),+ });+// Update parent with clean closed stateconst newState = {isOpen: false,diff --git a/autogpt_platform/frontend/src/tests/agent-dashboard.spec.ts b/autogpt_platform/frontend/src/tests/agent-dashboard.spec.tsindex 87dfff10ca..ea1629f929 100644--- a/autogpt_platform/frontend/src/tests/agent-dashboard.spec.ts+++ b/autogpt_platform/frontend/src/tests/agent-dashboard.spec.ts@@ -83,7 +83,7 @@ test("agent table delete action works correctly", async ({ page }) => {const rows = agentTable.getByTestId("agent-table-row");- // Delete button testing — delete the first agent in the list+ // Delete button testing — only works for PENDING submissionsconst beforeCount = await rows.count();if (beforeCount === 0) {@@ -91,11 +91,18 @@ test("agent table delete action works correctly", async ({ page }) => {return;}- const firstRow = rows.first();- const deletedSubmissionId = await firstRow.getAttribute("data-submission-id");- await firstRow.scrollIntoViewIfNeeded();+ // Find a PENDING submission to delete+ const pendingRow = rows.filter({ hasText: "Pending" }).first();+ if (!(await pendingRow.count())) {+ console.log("No pending agents available; skipping delete flow.");+ return;+ }- const delActionsButton = firstRow.getByTestId("agent-table-row-actions");+ const deletedSubmissionId =+ await pendingRow.getAttribute("data-submission-id");+ await pendingRow.scrollIntoViewIfNeeded();++ const delActionsButton = pendingRow.getByTestId("agent-table-row-actions");await delActionsButton.waitFor({ state: "visible", timeout: 10000 });await delActionsButton.scrollIntoViewIfNeeded();await delActionsButton.click();@@ -108,7 +115,7 @@ test("agent table delete action works correctly", async ({ page }) => {await isHidden(page.locator(`[data-submission-id="${deletedSubmissionId}"]`));});-test("edit action is unavailable for rejected agents (view only)", async ({+test("edit and delete actions are unavailable for non-pending submissions", async ({page,}) => {await page.goto("/profile/dashboard");@@ -118,27 +125,39 @@ test("edit action is unavailable for rejected agents (view only)", async ({const rows = agentTable.getByTestId("agent-table-row");+ // Test with rejected submissions (view only)const rejectedRow = rows.filter({ hasText: "Rejected" }).first();- if (!(await rejectedRow.count())) {- console.log("No rejected agents available; skipping rejected edit test.");- return;+ if (await rejectedRow.count()) {+ await rejectedRow.scrollIntoViewIfNeeded();+ const actionsButton = rejectedRow.getByTestId("agent-table-row-actions");+ await actionsButton.waitFor({ state: "visible", timeout: 10000 });+ await actionsButton.scrollIntoViewIfNeeded();+ await actionsButton.click();++ await expect(page.getByRole("menuitem", { name: "View" })).toBeVisible();+ await expect(page.getByRole("menuitem", { name: "Edit" })).toHaveCount(0);+ await expect(page.getByRole("menuitem", { name: "Delete" })).toHaveCount(0);++ // Close the menu+ await page.keyboard.press("Escape");}- await rejectedRow.scrollIntoViewIfNeeded();-- const actionsButton = rejectedRow.getByTestId("agent-table-row-actions");- await actionsButton.waitFor({ state: "visible", timeout: 10000 });- await actionsButton.scrollIntoViewIfNeeded();- await actionsButton.click();-- // Rejected should not show Edit, only View- await expect(page.getByRole("menuitem", { name: "View" })).toBeVisible();- await expect(page.getByRole("menuitem", { name: "Edit" })).toHaveCount(0);+ // Test with approved submissions (view only)+ const approvedRow = rows.filter({ hasText: "Approved" }).first();+ if (await approvedRow.count()) {+ await approvedRow.scrollIntoViewIfNeeded();+ const actionsButton = approvedRow.getByTestId("agent-table-row-actions");+ await actionsButton.waitFor({ state: "visible", timeout: 10000 });+ await actionsButton.scrollIntoViewIfNeeded();+ await actionsButton.click();++ await expect(page.getByRole("menuitem", { name: "View" })).toBeVisible();+ await expect(page.getByRole("menuitem", { name: "Edit" })).toHaveCount(0);+ await expect(page.getByRole("menuitem", { name: "Delete" })).toHaveCount(0);+ }});-test("editing an approved agent creates a new pending submission", async ({- page,-}) => {+test("editing a pending submission works correctly", async ({ page }) => {await page.goto("/profile/dashboard");const agentTable = page.getByTestId("agent-table");@@ -146,16 +165,17 @@ test("editing an approved agent creates a new pending submission", async ({const rows = agentTable.getByTestId("agent-table-row");- const approvedRow = rows.filter({ hasText: "Approved" }).first();- if (!(await approvedRow.count())) {- console.log("No approved agents available; skipping approved edit test.");+ // Find a PENDING submission to edit (only PENDING submissions can be edited)+ const pendingRow = rows.filter({ hasText: "Pending" }).first();+ if (!(await pendingRow.count())) {+ console.log("No pending agents available; skipping edit test.");return;}const beforeCount = await rows.count();- await approvedRow.scrollIntoViewIfNeeded();- const actionsButton = approvedRow.getByTestId("agent-table-row-actions");+ await pendingRow.scrollIntoViewIfNeeded();+ const actionsButton = pendingRow.getByTestId("agent-table-row-actions");await actionsButton.waitFor({ state: "visible", timeout: 10000 });await actionsButton.scrollIntoViewIfNeeded();await actionsButton.click();@@ -167,11 +187,11 @@ test("editing an approved agent creates a new pending submission", async ({const editModal = page.getByTestId("edit-agent-modal");await expect(editModal).toBeVisible();- const newTitle = `E2E Edit Approved ${Date.now()}`;+ const newTitle = `E2E Edit Pending ${Date.now()}`;await page.getByRole("textbox", { name: "Title" }).fill(newTitle);await page.getByRole("textbox", { name: "Changes Summary" })- .fill("E2E change - approved -> new pending submission");+ .fill("E2E change - updating pending submission");await page.getByRole("button", { name: "Update submission" }).click();await expect(editModal).not.toBeVisible();