diff --git a/site/src/pages/TaskPage/TaskAppIframe.tsx b/site/src/pages/TaskPage/TaskAppIframe.tsx new file mode 100644 index 0000000000000..1f247bfeaab71 --- /dev/null +++ b/site/src/pages/TaskPage/TaskAppIframe.tsx @@ -0,0 +1,40 @@ +import type { WorkspaceApp } from "api/typesGenerated"; +import { useAppLink } from "modules/apps/useAppLink"; +import type { Task } from "modules/tasks/tasks"; +import type { FC } from "react"; +import { cn } from "utils/cn"; + +type TaskAppIFrameProps = { + task: Task; + app: WorkspaceApp; + active: boolean; +}; + +export const TaskAppIFrame: FC = ({ + task, + app, + active, +}) => { + const agent = task.workspace.latest_build.resources + .flatMap((r) => r.agents) + .filter((a) => !!a) + .find((a) => a.apps.some((a) => a.id === app.id)); + + if (!agent) { + throw new Error(`Agent for app ${app.id} not found in task workspace`); + } + + const link = useAppLink(app, { + agent, + workspace: task.workspace, + }); + + return ( +