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.
feat(frontend): add "Jump Back In" button to Library page (#12387)
Ubbe048fb06b0a99
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/JumpBackIn/JumpBackIn.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/JumpBackIn/JumpBackIn.tsxnew file mode 100644index 0000000000..35c12c693e--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/JumpBackIn/JumpBackIn.tsx@@ -0,0 +1,40 @@+"use client";++import { ArrowRight, Lightning } from "@phosphor-icons/react";+import NextLink from "next/link";++import { Button } from "@/components/atoms/Button/Button";+import { Text } from "@/components/atoms/Text/Text";+import { useJumpBackIn } from "./useJumpBackIn";++export function JumpBackIn() {+ const { agent, isLoading } = useJumpBackIn();++ if (isLoading || !agent) {+ return null;+ }++ return (+ <div className="flex items-center justify-between rounded-large border border-zinc-200 bg-gradient-to-r from-zinc-50 to-white px-5 py-4">+ <div className="flex items-center gap-3">+ <div className="flex h-9 w-9 items-center justify-center rounded-full bg-zinc-900">+ <Lightning size={18} weight="fill" className="text-white" />+ </div>+ <div className="flex flex-col">+ <Text variant="small" className="text-zinc-500">+ Continue where you left off+ </Text>+ <Text variant="body-medium" className="text-zinc-900">+ {agent.name}+ </Text>+ </div>+ </div>+ <NextLink href={`/library/agents/${agent.id}`}>+ <Button variant="primary" size="small" className="gap-1.5">+ Jump Back In+ <ArrowRight size={16} />+ </Button>+ </NextLink>+ </div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/JumpBackIn/useJumpBackIn.ts b/autogpt_platform/frontend/src/app/(platform)/library/components/JumpBackIn/useJumpBackIn.tsnew file mode 100644index 0000000000..c77fed726a--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/JumpBackIn/useJumpBackIn.ts@@ -0,0 +1,28 @@+"use client";++import { useGetV2ListLibraryAgents } from "@/app/api/__generated__/endpoints/library/library";+import { okData } from "@/app/api/helpers";++export function useJumpBackIn() {+ const { data, isLoading } = useGetV2ListLibraryAgents(+ {+ page: 1,+ page_size: 1,+ sort_by: "updatedAt",+ },+ {+ query: { select: okData },+ },+ );++ // The API doesn't include execution data by default (include_executions is+ // internal to the backend), so recent_executions is always empty here.+ // We use the most recently updated agent as the "jump back in" candidate+ // instead — updatedAt is the best available proxy for recent activity.+ const agent = data?.agents[0] ?? null;++ return {+ agent,+ isLoading,+ };+}diff --git a/autogpt_platform/frontend/src/app/(platform)/library/page.tsx b/autogpt_platform/frontend/src/app/(platform)/library/page.tsxindex 2510bd8f33..d8dad44dba 100644--- a/autogpt_platform/frontend/src/app/(platform)/library/page.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/library/page.tsx@@ -2,6 +2,7 @@import { useEffect, useState, useCallback } from "react";import { HeartIcon, ListIcon } from "@phosphor-icons/react";+import { JumpBackIn } from "./components/JumpBackIn/JumpBackIn";import { LibraryActionHeader } from "./components/LibraryActionHeader/LibraryActionHeader";import { LibraryAgentList } from "./components/LibraryAgentList/LibraryAgentList";import { Tab } from "./components/LibraryTabs/LibraryTabs";@@ -38,6 +39,7 @@ export default function LibraryPage() {onAnimationComplete={handleFavoriteAnimationComplete}><main className="pt-160 container min-h-screen space-y-4 pb-20 pt-16 sm:px-8 md:px-12">+ <JumpBackIn /><LibraryActionHeader setSearchTerm={setSearchTerm} /><LibraryAgentListsearchTerm={searchTerm}