({ task, workspace })
| 31 | const TERMINAL_TAB_ID = "terminal"; |
| 32 | |
| 33 | export const TaskApps: FC<TaskAppsProps> = ({ task, workspace }) => { |
| 34 | const allApps = getAllAppsWithAgent(workspace); |
| 35 | const apps = allApps.filter( |
| 36 | // The Chat UI app will be displayed in the sidebar, so we don't want to |
| 37 | // show it as a web app. |
| 38 | (app) => app.id !== task.workspace_app_id && !app.hidden, |
| 39 | ); |
| 40 | const [embeddedApps, externalApps] = splitEmbeddedAndExternalApps(apps); |
| 41 | const [activeAppId, setActiveAppId] = useState(embeddedApps.at(0)?.id); |
| 42 | const hasAvailableAppsToDisplay = |
| 43 | embeddedApps.length > 0 || externalApps.length > 0; |
| 44 | const taskAgent = allApps.at(0)?.agent; |
| 45 | const terminalHref = getTerminalHref({ |
| 46 | username: task.owner_name, |
| 47 | workspace: task.workspace_name, |
| 48 | agent: taskAgent?.name, |
| 49 | }); |
| 50 | const isTerminalActive = activeAppId === TERMINAL_TAB_ID; |
| 51 | |
| 52 | return ( |
| 53 | <main className="flex flex-col h-full"> |
| 54 | {hasAvailableAppsToDisplay && ( |
| 55 | <div className="w-full flex items-center border-0 border-b border-border border-solid"> |
| 56 | <ScrollArea className="max-w-full"> |
| 57 | <div className="flex w-max gap-2 items-center p-2 pb-0"> |
| 58 | {embeddedApps.map((app) => ( |
| 59 | <TaskAppTab |
| 60 | key={app.id} |
| 61 | workspace={workspace} |
| 62 | app={app} |
| 63 | active={app.id === activeAppId} |
| 64 | onClick={(e) => { |
| 65 | e.preventDefault(); |
| 66 | setActiveAppId(app.id); |
| 67 | }} |
| 68 | /> |
| 69 | ))} |
| 70 | <TaskTab |
| 71 | to={terminalHref} |
| 72 | active={isTerminalActive} |
| 73 | onClick={(e) => { |
| 74 | e.preventDefault(); |
| 75 | setActiveAppId(TERMINAL_TAB_ID); |
| 76 | }} |
| 77 | > |
| 78 | <TerminalIcon /> |
| 79 | Terminal |
| 80 | </TaskTab> |
| 81 | </div> |
| 82 | <ScrollBar orientation="horizontal" className="h-2" /> |
| 83 | </ScrollArea> |
| 84 | |
| 85 | {externalApps.length > 0 && ( |
| 86 | <ExternalAppsDropdown |
| 87 | workspace={workspace} |
| 88 | externalApps={externalApps} |
| 89 | /> |
| 90 | )} |
nothing calls this directly
no test coverage detected