Skip to content

WIP- ci(frontend,design): add storybook builds to the frontend #9859

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 62 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
52af83c
add chromatic in github ci
Abhi1992002 Apr 22, 2025
fcf6f3b
add mock backend provider in preview.tsx
Abhi1992002 Apr 22, 2025
f341965
Merge branch 'dev' into abhi/ci-chromatic
Abhi1992002 Apr 23, 2025
3989bdd
fix storybook mock clients and add better documentaion
Abhi1992002 Apr 23, 2025
a7d4de6
fix tailwind fonts in storybook
Abhi1992002 Apr 23, 2025
5e73bcc
fix FeaturedAgent Component and its stories
Abhi1992002 Apr 23, 2025
34345db
fix missing supabase env secret error in chromatic by adding dummy
Abhi1992002 Apr 23, 2025
335e4a6
rebuild all stories with new env
Abhi1992002 Apr 24, 2025
4fd1167
Merge branch 'dev' into abhi/ci-chromatic
Abhi1992002 Apr 24, 2025
dc7f482
fix unhandled request in FeaturedAgentCard
Abhi1992002 Apr 24, 2025
fda57a4
fix AgentInfo component and its stories
Abhi1992002 Apr 24, 2025
dfa29b9
fixing Agent Table phase 1
Abhi1992002 Apr 24, 2025
5679d6e
feat(backend): Use forkserver on process creation if possible (#9864)
majdyz Apr 24, 2025
d76e2ac
feat(backend): Expose execution prometheus metrics (#9866)
majdyz Apr 24, 2025
0b22456
Update repo-close-stale-issues.yml
Torantulino Apr 23, 2025
bdbf8f2
fix(backend): Strip secrets, credentials when forking agent (#9874)
kcze Apr 24, 2025
ee4ebc1
feat(frontend): Update "Edit a copy" modal and buttons (#9876)
kcze Apr 24, 2025
c00d7a9
fix(block): Fix Smart Decision Block missing input beads & incompabil…
majdyz Apr 24, 2025
f60d44e
feat(frontend): Add billing page toggle (#9877)
majdyz Apr 24, 2025
4ef5c5c
Merge branch 'dev' into abhi/ci-chromatic
Abhi1992002 Apr 25, 2025
6b44ca5
complete fix of AgentTable
Abhi1992002 Apr 25, 2025
073f9f4
fix FeaturedSection components and story
Abhi1992002 Apr 25, 2025
01557a6
Merge branch 'dev' into abhi/ci-chromatic
Abhi1992002 Apr 26, 2025
36bda1c
change default iamge
Abhi1992002 Apr 26, 2025
35da036
fix AgentSection and StoreCard
Abhi1992002 Apr 26, 2025
1413848
fix Creator card
Abhi1992002 Apr 26, 2025
b3d4d81
fix FeaturedCreator stories
Abhi1992002 Apr 26, 2025
94f0f51
fix Filter Chips
Abhi1992002 Apr 26, 2025
43a508d
fix search bar
Abhi1992002 Apr 26, 2025
c26b5dc
fix search bar story
Abhi1992002 Apr 26, 2025
50b2fc3
Merge branch 'dev' into abhi/ci-chromatic
Abhi1992002 Apr 28, 2025
653a7f4
fix mock client and Become a cretor section
Abhi1992002 Apr 28, 2025
a6fcb3a
fix Hero section component and stories
Abhi1992002 Apr 28, 2025
36578e2
fix PublishAgentSelect and PublishAgentPopoutcomponent
Abhi1992002 Apr 28, 2025
f4e0735
fix PublishAgentSelectInfo Component
Abhi1992002 Apr 28, 2025
dc16964
fix lint
Abhi1992002 Apr 28, 2025
cf015e8
Merge branch 'dev' into abhi/ci-chromatic
Abhi1992002 Apr 30, 2025
4d6ef9f
fix all Publish Components
Abhi1992002 Apr 30, 2025
b499b6a
add new story for search filter chips
Abhi1992002 Apr 30, 2025
3c2fb6a
add new story for search filter chips
Abhi1992002 Apr 30, 2025
bb7c8ba
fix all component of marketplace
Abhi1992002 Apr 30, 2025
a7926e1
fix button tests
Abhi1992002 Apr 30, 2025
234ce73
Fix all tests of stories
Abhi1992002 Apr 30, 2025
2d5f541
small fixes
Abhi1992002 Apr 30, 2025
5ba9495
add new design changes in some components
Abhi1992002 Apr 30, 2025
368df7b
fix all components of marketplace and profile according to new design
Abhi1992002 May 1, 2025
781d8eb
Merge branch 'dev' into abhi/ci-chromatic
Abhi1992002 May 1, 2025
86cbd6e
Merge branch 'dev' into abhi/ci-chromatic
Abhi1992002 May 2, 2025
5d198e4
fix layout of complete website
Abhi1992002 May 5, 2025
eadb3e8
Merge branch 'dev' into abhi/ci-chromatic
Abhi1992002 May 5, 2025
ac9b0ad
fix all components
Abhi1992002 May 5, 2025
5e7958c
fix ui tests
Abhi1992002 May 5, 2025
212c105
fix login tests on chromium
Abhi1992002 May 5, 2025
249d613
fix all stories
Abhi1992002 May 5, 2025
fd345f2
add new default images for testing
Abhi1992002 May 5, 2025
1acc000
Merge branch 'dev' into abhi/ci-chromatic
Abhi1992002 May 5, 2025
d93b6ec
Merge branch 'dev' into abhi/ci-chromatic
Abhi1992002 May 6, 2025
fe472e2
add custom buttons on agent page
Abhi1992002 May 6, 2025
8eedfad
fix format
Abhi1992002 May 6, 2025
76db887
Merge branch 'dev' into abhi/ci-chromatic
Abhi1992002 May 7, 2025
4fa44df
Merge branch 'dev' into abhi/ci-chromatic
Abhi1992002 May 8, 2025
7449a37
Merge branch 'dev' into abhi/ci-chromatic
Abhi1992002 May 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/platform-frontend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,30 @@ jobs:
run: |
yarn type-check

design:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "21"

- name: Install dependencies
run: |
yarn install --frozen-lockfile

- name: Run Chromatic
uses: chromaui/action@latest
with:
# ⚠️ Make sure to configure a `CHROMATIC_PROJECT_TOKEN` repository secret
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
workingDir: autogpt_platform/frontend

test:
runs-on: ubuntu-latest
strategy:
Expand Down
16 changes: 15 additions & 1 deletion autogpt_platform/frontend/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,27 @@ const config: StorybookConfig = {
"@storybook/addon-essentials",
"@storybook/addon-interactions",
],
env: {
NEXT_PUBLIC_SUPABASE_URL: "https://your-project.supabase.co",
NEXT_PUBLIC_SUPABASE_ANON_KEY: "your-anon-key",
},
features: {
experimentalRSC: true,
},
framework: {
name: "@storybook/nextjs",
options: {},
},
staticDirs: ["../public"],
staticDirs: [
"../public",
{
from: "../node_modules/geist/dist/fonts/geist-sans",
to: "/fonts/geist-sans",
},
{
from: "../node_modules/geist/dist/fonts/geist-mono",
to: "/fonts/geist-mono",
},
],
};
export default config;
23 changes: 0 additions & 23 deletions autogpt_platform/frontend/.storybook/preview.ts

This file was deleted.

61 changes: 61 additions & 0 deletions autogpt_platform/frontend/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React from "react";
import type { Preview } from "@storybook/react";
import { initialize, mswLoader } from "msw-storybook-addon";
import { Inter, Poppins } from "next/font/google";
import localFont from "next/font/local";
import "../src/app/globals.css";
import { Providers } from "../src/app/providers";

const poppins = Poppins({
subsets: ["latin"],
weight: ["400", "500", "600", "700"],
variable: "--font-poppins",
});

const inter = Inter({ subsets: ["latin"], variable: "--font-inter" });

const GeistSans = localFont({
src: "../fonts/geist-sans/Geist-Variable.woff2",
variable: "--font-geist-sans",
});

const GeistMono = localFont({
src: "../fonts/geist-mono/GeistMono-Variable.woff2",
variable: "--font-geist-mono",
});

// Initialize MSW
initialize();

const preview: Preview = {
parameters: {
nextjs: {
appDirectory: true,
},
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
layout: "fullscreen",
},
decorators: [
(Story, context) => {
const mockOptions = context.parameters.mockBackend || {};

return (
<div
className={`${poppins.variable} ${inter.variable} ${GeistMono.variable} ${GeistSans.variable}`}
>
<Providers mockClientProps={mockOptions}>
<Story />
</Providers>
</div>
);
},
],
loaders: [mswLoader],
};

export default preview;
60 changes: 60 additions & 0 deletions autogpt_platform/frontend/.storybook/stoybook_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# For Client-Side Components

When communicating with the server in client components, use the `useBackendAPI` hook. It automatically detects when running in a Storybook environment and switches to the mock client.

To provide custom mock data instead of the default values, add the `mockBackend` parameter in your stories:

```tsx
export const MyStory = {
parameters: {
mockBackend: {
credits: 100,
isAuthenticated: true,
// Other custom mock data
},
},
};
```

# For Server-Side Components

The server-based Supabase client automatically switches between real requests and mock responses.

For server-side components, use the following pattern to select between backend client and mock client:

```tsx
const api = process.env.STORYBOOK ? new MockClient() : new BackendAPI();
```

You need to override specific API request methods in your mock client implementation. If you don't override a method, you can use the default methods provided by `BackendAPI` in both server-side and client-side environments.

To use custom mock data in server components, pass it directly to the `MockClient` constructor:

```tsx
const api = process.env.STORYBOOK
? new MockClient({ credits: 200, isAuthenticated: true })
: new BackendAPI();
```

> Note: For client components, always use the `mockBackend` parameter in stories instead.

# Using MSW

If you haven't overridden an API request method in your mock client, you can use Mock Service Worker (MSW) to intercept HTTP requests from both the browser and Node.js environments, then respond with custom mock data:

```tsx
// In your story
export const WithMSW = {
parameters: {
msw: {
handlers: [
http.get("/api/user", () => {
return HttpResponse.json({ name: "John", role: "admin" });
}),
],
},
},
};
```

Currently, it doesn't have support for client-side Supabase client and custom data for Supabase server-side client. You could use MSW for both cases.
Binary file added autogpt_platform/frontend/public/agpt-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions autogpt_platform/frontend/public/agpt-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 6 additions & 5 deletions autogpt_platform/frontend/src/app/(platform)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ export default function PlatformLayout({ children }: { children: ReactNode }) {
<Navbar
links={[
{
name: "Marketplace",
href: "/marketplace",
name: "Home",
href: "/library",
},
{
name: "Library",
href: "/library",
name: "Marketplace",
href: "/marketplace",
},

{
name: "Build",
href: "/build",
Expand Down Expand Up @@ -62,7 +63,7 @@ export default function PlatformLayout({ children }: { children: ReactNode }) {
},
]}
/>
<main>{children}</main>
<main className="w-full">{children}</main>
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,62 +56,49 @@ export default async function Page({

const breadcrumbs = [
{ name: "Marketplace", link: "/marketplace" },
{
name: agent.creator,
link: `/marketplace/creator/${encodeURIComponent(agent.creator)}`,
},
{ name: agent.agent_name, link: "#" },
];

return (
<div className="mx-auto w-screen max-w-[1360px]">
<main className="mt-5 px-4">
<BreadCrumbs items={breadcrumbs} />

<div className="mt-4 flex flex-col items-start gap-4 sm:mt-6 sm:gap-6 md:mt-8 md:flex-row md:gap-8">
<div className="w-full md:w-auto md:shrink-0">
<AgentInfo
user={user}
name={agent.agent_name}
creator={agent.creator}
shortDescription={agent.sub_heading}
longDescription={agent.description}
rating={agent.rating}
runs={agent.runs}
categories={agent.categories}
lastUpdated={agent.updated_at}
version={agent.versions[agent.versions.length - 1]}
storeListingVersionId={agent.store_listing_version_id}
libraryAgent={libraryAgent}
/>
</div>
<AgentImages
images={
agent.agent_video
? [agent.agent_video, ...agent.agent_image]
: agent.agent_image
}
<main className="mt-9 px-10">
<BreadCrumbs items={breadcrumbs} />
<div className="mt-4 flex flex-col items-start gap-4 sm:mt-6 sm:gap-6 md:mt-8 md:flex-row md:gap-8">
<div className="w-full md:w-auto md:shrink-0">
<AgentInfo
user={user}
name={agent.agent_name}
creator={agent.creator}
shortDescription={agent.sub_heading}
longDescription={agent.description}
rating={agent.rating}
runs={agent.runs}
categories={agent.categories}
lastUpdated={agent.updated_at}
version={agent.versions[agent.versions.length - 1]}
storeListingVersionId={agent.store_listing_version_id}
libraryAgent={libraryAgent}
/>
</div>
<Separator className="mb-[25px] mt-[60px]" />
<AgentsSection
margin="32px"
agents={otherAgents.agents}
sectionTitle={`Other agents by ${agent.creator}`}
/>
<Separator className="mb-[25px] mt-[60px]" />
<AgentsSection
margin="32px"
agents={similarAgents.agents}
sectionTitle="Similar agents"
/>
<Separator className="mb-[25px] mt-[60px]" />
<BecomeACreator
title="Become a Creator"
description="Join our ever-growing community of hackers and tinkerers"
buttonText="Become a Creator"
<AgentImages
images={
agent.agent_video
? [agent.agent_video, ...agent.agent_image]
: agent.agent_image
}
/>
</main>
</div>
</div>
<Separator className="mb-9 mt-7" />
<AgentsSection
agents={otherAgents.agents}
sectionTitle={`Other agents by ${agent.creator}`}
/>
<Separator className="mb-9 mt-11" />
<AgentsSection
agents={similarAgents.agents}
sectionTitle="Similar agents"
/>
<Separator className="mb-9 mt-11" />
<BecomeACreator title="Become a Creator" buttonText="Become a Creator" />
</main>
);
}
Loading
Loading