-
Notifications
You must be signed in to change notification settings - Fork 943
feat: add task page #18076
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
Merged
Merged
feat: add task page #18076
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import type { WorkspaceAppStatus } from "api/typesGenerated"; | ||
import { Spinner } from "components/Spinner/Spinner"; | ||
import { | ||
CircleAlertIcon, | ||
CircleCheckIcon, | ||
HourglassIcon, | ||
TriangleAlertIcon, | ||
} from "lucide-react"; | ||
import type { FC } from "react"; | ||
import { cn } from "utils/cn"; | ||
|
||
type AppStatusIconProps = { | ||
status: WorkspaceAppStatus; | ||
latest: boolean; | ||
className?: string; | ||
}; | ||
|
||
export const AppStatusIcon: FC<AppStatusIconProps> = ({ | ||
status, | ||
latest, | ||
className: customClassName, | ||
}) => { | ||
const className = cn(["size-4 shrink-0", customClassName]); | ||
|
||
switch (status.state) { | ||
case "complete": | ||
return ( | ||
<CircleCheckIcon className={cn([className, "text-content-success"])} /> | ||
); | ||
case "failure": | ||
return ( | ||
<CircleAlertIcon className={cn([className, "text-content-warning"])} /> | ||
); | ||
case "working": | ||
return latest ? ( | ||
<Spinner size="sm" className="shrink-0" loading /> | ||
) : ( | ||
<HourglassIcon className={cn([className, "text-highlight-sky"])} /> | ||
); | ||
default: | ||
return ( | ||
<TriangleAlertIcon | ||
className={cn([className, "text-content-secondary"])} | ||
/> | ||
); | ||
} | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { Workspace } from "api/typesGenerated"; | ||
|
||
export const AI_PROMPT_PARAMETER_NAME = "AI Prompt"; | ||
|
||
export type Task = { | ||
workspace: Workspace; | ||
prompt: string; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { spyOn } from "@storybook/test"; | ||
import { | ||
MockFailedWorkspace, | ||
MockStartingWorkspace, | ||
MockStoppedWorkspace, | ||
MockWorkspace, | ||
MockWorkspaceAgent, | ||
MockWorkspaceApp, | ||
MockWorkspaceAppStatus, | ||
MockWorkspaceResource, | ||
mockApiError, | ||
} from "testHelpers/entities"; | ||
import { withProxyProvider } from "testHelpers/storybook"; | ||
import TaskPage, { data } from "./TaskPage"; | ||
|
||
const meta: Meta<typeof TaskPage> = { | ||
title: "pages/TaskPage", | ||
component: TaskPage, | ||
parameters: { | ||
layout: "fullscreen", | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof TaskPage>; | ||
|
||
export const Loading: Story = { | ||
beforeEach: () => { | ||
spyOn(data, "fetchTask").mockImplementation( | ||
() => new Promise((res) => 1000 * 60 * 60), | ||
); | ||
}, | ||
}; | ||
|
||
export const LoadingError: Story = { | ||
beforeEach: () => { | ||
spyOn(data, "fetchTask").mockRejectedValue( | ||
mockApiError({ | ||
message: "Failed to load task", | ||
detail: "You don't have permission to access this resource.", | ||
}), | ||
); | ||
}, | ||
}; | ||
|
||
export const WaitingOnBuild: Story = { | ||
beforeEach: () => { | ||
spyOn(data, "fetchTask").mockResolvedValue({ | ||
prompt: "Create competitors page", | ||
workspace: MockStartingWorkspace, | ||
}); | ||
}, | ||
}; | ||
|
||
export const WaitingOnStatus: Story = { | ||
beforeEach: () => { | ||
spyOn(data, "fetchTask").mockResolvedValue({ | ||
prompt: "Create competitors page", | ||
workspace: { | ||
...MockWorkspace, | ||
latest_app_status: null, | ||
}, | ||
}); | ||
}, | ||
}; | ||
|
||
export const FailedBuild: Story = { | ||
beforeEach: () => { | ||
spyOn(data, "fetchTask").mockResolvedValue({ | ||
prompt: "Create competitors page", | ||
workspace: MockFailedWorkspace, | ||
}); | ||
}, | ||
}; | ||
|
||
export const TerminatedBuild: Story = { | ||
beforeEach: () => { | ||
spyOn(data, "fetchTask").mockResolvedValue({ | ||
prompt: "Create competitors page", | ||
workspace: MockStoppedWorkspace, | ||
}); | ||
}, | ||
}; | ||
|
||
export const TerminatedBuildWithStatus: Story = { | ||
beforeEach: () => { | ||
spyOn(data, "fetchTask").mockResolvedValue({ | ||
prompt: "Create competitors page", | ||
workspace: { | ||
...MockStoppedWorkspace, | ||
latest_app_status: MockWorkspaceAppStatus, | ||
}, | ||
}); | ||
}, | ||
}; | ||
|
||
export const Active: Story = { | ||
decorators: [withProxyProvider()], | ||
beforeEach: () => { | ||
spyOn(data, "fetchTask").mockResolvedValue({ | ||
prompt: "Create competitors page", | ||
workspace: { | ||
...MockWorkspace, | ||
latest_build: { | ||
...MockWorkspace.latest_build, | ||
resources: [ | ||
{ | ||
...MockWorkspaceResource, | ||
agents: [ | ||
{ | ||
...MockWorkspaceAgent, | ||
apps: [ | ||
{ | ||
...MockWorkspaceApp, | ||
id: "cloud-code", | ||
display_name: "Cloud Code", | ||
icon: "https://uxwing.com/wp-content/themes/uxwing/download/brands-and-social-media/claude-ai-icon.png", | ||
url: `${window.location.protocol}/iframe.html?viewMode=story&id=pages-terminal--ready&args=&globals=`, | ||
external: true, | ||
statuses: [ | ||
MockWorkspaceAppStatus, | ||
{ | ||
...MockWorkspaceAppStatus, | ||
id: "2", | ||
message: "Planning changes", | ||
state: "working", | ||
}, | ||
], | ||
}, | ||
{ | ||
...MockWorkspaceApp, | ||
id: "vscode", | ||
display_name: "VSCode", | ||
icon: "/icon/code.svg", | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
latest_app_status: { | ||
...MockWorkspaceAppStatus, | ||
app_id: "cloud-code", | ||
}, | ||
}, | ||
}); | ||
}, | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo: cloud-code -> claude-code |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably shouldn't use externally hosted images.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do this for many other storybook tests 😄 it has not been a problem so far
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
/icons/claude.svg