Skip to content

feat(platform/library): Allow sorting Agents by Last Execution Time #9871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

Keerthi421
Copy link

@Keerthi421 Keerthi421 commented Apr 23, 2025

Changes 🏗️

This PR implements a new sorting option in the Library view to order agents by their last execution time rather than last edit time. This addresses a common user need to quickly access recently run agents, regardless of how they were executed (via GUI or otherwise).

-->Added LAST_EXECUTION to LibraryAgentSortEnum in types.ts
-->Updated the dropdown in library-sort-menu.tsx to include a "Last Run" option
-->Modified the placeholder text based on the selected sort option
-->Changed the default sort behavior in state-provider.tsx to LAST_EXECUTION
-->Adjusted API request logic to pass lastExecution as the sort key, enabling backend-side sorting by run time
-->Ensured sorting accounts for all executions (manual and automatic)
#9860

@Keerthi421 Keerthi421 requested a review from a team as a code owner April 23, 2025 12:04
@Keerthi421 Keerthi421 requested review from Swiftyos and kcze and removed request for a team April 23, 2025 12:04
@github-project-automation github-project-automation bot moved this to 🆕 Needs initial review in AutoGPT development kanban Apr 23, 2025
@CLAassistant
Copy link

CLAassistant commented Apr 23, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Default Value Inconsistency

The component sets a defaultValue for the Select component but also implements dynamic placeholder text. This could lead to UI inconsistencies where the displayed text doesn't match the actual selected value.

<Select onValueChange={handleSortChange} defaultValue={librarySort}>
  <SelectTrigger className="ml-1 w-fit space-x-1 border-none px-0 text-base underline underline-offset-4 shadow-none">
    <ArrowDownNarrowWideIcon className="h-4 w-4 sm:hidden" />
    <SelectValue placeholder={getPlaceholderText()} />

Copy link
Contributor

This PR targets the master branch but does not come from dev or a hotfix/* branch.

Automatically setting the base branch to dev.

@github-actions github-actions bot added platform/frontend AutoGPT Platform - Front end platform/backend AutoGPT Platform - Back end labels Apr 23, 2025
@github-actions github-actions bot changed the base branch from master to dev April 23, 2025 12:04
Copy link

deepsource-io bot commented Apr 23, 2025

Here's the code health analysis summary for commits 1e3236a..9c19fe0. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript✅ Success
❗ 5 occurences introduced
🎯 6 occurences resolved
View Check ↗
DeepSource Python LogoPython✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

Copy link

netlify bot commented Apr 23, 2025

Deploy Preview for auto-gpt-docs ready!

Name Link
🔨 Latest commit 9c19fe0
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/6812f84124bc2a00086b5999
😎 Deploy Preview https://deploy-preview-9871--auto-gpt-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Apr 24, 2025

Deploy Preview for auto-gpt-docs-dev ready!

Name Link
🔨 Latest commit 9c19fe0
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs-dev/deploys/6812f8416a4459000844acce
😎 Deploy Preview https://deploy-preview-9871--auto-gpt-docs-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Torantulino Torantulino requested review from Pwuts and Copilot and removed request for Swiftyos April 26, 2025 11:02
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces support for sorting agents by their last execution time in the Library view.

  • Added LAST_EXECUTION to the sort enum in types.ts.
  • Updated the library-sort-menu UI to display a "Last Run" option and to use the proper placeholder text.
  • Changed the default sort behavior in state-provider.tsx to use LAST_EXECUTION.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
autogpt_platform/frontend/src/lib/autogpt-server-api/types.ts Added new enum value LAST_EXECUTION to support sorting by last execution time.
autogpt_platform/frontend/src/components/library/library-sort-menu.tsx Modified the dropdown to include a "Last Run" option and updated placeholder text logic accordingly.
autogpt_platform/frontend/src/app/(platform)/library/state-provider.tsx Updated the default sort state from UPDATED_AT to LAST_EXECUTION.

@Torantulino
Copy link
Member

Hey @Keerthi421, welcome to the AutoGPT community!
Thank you so much for picking this ticket up.

To help us get this merged, could you please run the formatter and sign the CLA?

@Pwuts Pwuts changed the title fix:Add Support for Sorting Agents by Last Execution Time in Library … feat(platform): Add Support for Sorting Agents by Last Execution Time in Library … Apr 26, 2025
@Pwuts Pwuts changed the title feat(platform): Add Support for Sorting Agents by Last Execution Time in Library … feat(platform/library): Allow sorting Agents by Last Execution Time Apr 26, 2025
Copy link
Member

@Pwuts Pwuts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for picking this up! This PR is still missing an important piece though: it adds a frontend option lastExecution, but this sorting option also needs a backend implementation!

The enum is defined here:

class LibraryAgentSort(str, Enum):
"""Possible sort options for sorting library agents."""
CREATED_AT = "createdAt"
UPDATED_AT = "updatedAt"

Check out all of its references to find the other code that needs to be updated.

@@ -28,13 +28,26 @@ export default function LibrarySortMenu(): React.ReactNode {
setAgentLoading(false);
};

const getPlaceholderText = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls make this a memoized variable placeholderText

Comment on lines 32 to 41
switch (librarySort) {
case LibraryAgentSortEnum.CREATED_AT:
return "Creation Date";
case LibraryAgentSortEnum.UPDATED_AT:
return "Last Modified";
case LibraryAgentSortEnum.LAST_EXECUTION:
return "Last Run";
default:
return "Last Modified";
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd use an object mapping instead (e.g. { LibraryAgentSortEnum.CREATED_AT: "Creation Date", ... }[librarySort])

@@ -44,6 +57,9 @@ export default function LibrarySortMenu(): React.ReactNode {
<SelectItem value={LibraryAgentSortEnum.UPDATED_AT}>
Last Modified
</SelectItem>
<SelectItem value={LibraryAgentSortEnum.LAST_EXECUTION}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this list should be a mapping expression using LibraryAgentSortEnum

@github-project-automation github-project-automation bot moved this from 🆕 Needs initial review to 🚧 Needs work in AutoGPT development kanban Apr 26, 2025
@ntindle ntindle requested a review from Pwuts April 28, 2025 19:23
@Torantulino Torantulino requested a review from Copilot April 30, 2025 17:06
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new sorting option to order library agents by their last execution time instead of the last modified time.

  • Added LAST_EXECUTION to the LibraryAgentSortEnum in frontend and backend.
  • Updated the dropdown in the library sort menu to include a "Last Run" option.
  • Adjusted the API request logic in the backend to support sorting agents by their last execution time.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
autogpt_platform/frontend/src/lib/autogpt-server-api/types.ts Added LAST_EXECUTION to the LibraryAgentSortEnum.
autogpt_platform/frontend/src/components/library/library-sort-menu.tsx Updated dropdown options in the sort menu to include a new "Last Run" label and use a memoized placeholder.
autogpt_platform/frontend/src/app/(platform)/library/state-provider.tsx Changed the default sort behavior to LAST_EXECUTION.
autogpt_platform/backend/backend/server/v2/library/model.py Added LAST_EXECUTION to the backend LibraryAgentSort enum.
autogpt_platform/backend/backend/server/v2/library/db.py Modified the order_by logic to support backend sorting by lastExecution with a fallback to updatedAt.

Copy link
Member

@Pwuts Pwuts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the changes made, I'm happy. Now you just have to convince the CI. :)

@github-project-automation github-project-automation bot moved this from 🚧 Needs work to 👍🏼 Mergeable in AutoGPT development kanban May 5, 2025
@Keerthi421
Copy link
Author

@Pwuts Thankyou , I will work on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform/backend AutoGPT Platform - Back end platform/frontend AutoGPT Platform - Front end Review effort 2/5 size/m
Projects
Status: 👍🏼 Mergeable
Status: No status
Development

Successfully merging this pull request may close these issues.

4 participants