MCPcopy Index your code
hub / github.com/coder/coder / TaskApps

Function TaskApps

site/src/pages/TaskPage/TaskApps.tsx:33–133  ·  view source on GitHub ↗
({ task, workspace })

Source from the content-addressed store, hash-verified

31const TERMINAL_TAB_ID = "terminal";
32
33export 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 )}

Callers

nothing calls this directly

Calls 6

getAllAppsWithAgentFunction · 0.90
getTerminalHrefFunction · 0.90
cnFunction · 0.90
docsFunction · 0.90
filterMethod · 0.80

Tested by

no test coverage detected