Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit02de067

Browse files
refactor(site): remove usage ofthrow inTaskApps.tsx (#19235)
1 parentffbd583 commit02de067

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

‎site/src/pages/TaskPage/TaskApps.tsx‎

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ type TaskAppsProps = {
2323
task:Task;
2424
};
2525

26+
typeAppWithAgent={
27+
app:WorkspaceApp;
28+
agent:WorkspaceAgent;
29+
};
30+
2631
exportconstTaskApps:FC<TaskAppsProps>=({ task})=>{
2732
constagents=task.workspace.latest_build.resources
2833
.flatMap((r)=>r.agents)
@@ -31,27 +36,34 @@ export const TaskApps: FC<TaskAppsProps> = ({ task }) => {
3136
// The Chat UI app will be displayed in the sidebar, so we don't want to show
3237
// it here
3338
constapps=agents
34-
.flatMap((a)=>a?.apps)
39+
.flatMap((agent)=>
40+
agent.apps.map((app)=>({
41+
app,
42+
agent,
43+
})),
44+
)
3545
.filter(
36-
(a)=>!!a&&a.id!==task.workspace.latest_build.ai_task_sidebar_app_id,
46+
({ app})=>
47+
!!app&&app.id!==task.workspace.latest_build.ai_task_sidebar_app_id,
3748
);
3849

39-
constembeddedApps=apps.filter((app)=>!app.external);
40-
constexternalApps=apps.filter((app)=>app.external);
50+
constembeddedApps=apps.filter(({app})=>!app.external);
51+
constexternalApps=apps.filter(({app})=>app.external);
4152

4253
const[activeAppId,setActiveAppId]=useState<string|undefined>(
43-
embeddedApps[0]?.id,
54+
embeddedApps[0]?.app.id,
4455
);
4556

4657
return(
4758
<mainclassName="flex flex-col">
4859
<divclassName="w-full flex items-center border-0 border-b border-border border-solid">
4960
<divclassName="p-2 pb-0 flex gap-2 items-center">
50-
{embeddedApps.map((app)=>(
61+
{embeddedApps.map(({app, agent})=>(
5162
<TaskAppTab
5263
key={app.id}
5364
task={task}
5465
app={app}
66+
agent={agent}
5567
active={app.id===activeAppId}
5668
onClick={(e)=>{
5769
e.preventDefault();
@@ -72,7 +84,7 @@ export const TaskApps: FC<TaskAppsProps> = ({ task }) => {
7284

7385
{embeddedApps.length>0 ?(
7486
<divclassName="flex-1">
75-
{embeddedApps.map((app)=>{
87+
{embeddedApps.map(({app})=>{
7688
return(
7789
<TaskAppIFrame
7890
key={app.id}
@@ -108,7 +120,7 @@ export const TaskApps: FC<TaskAppsProps> = ({ task }) => {
108120
typeTaskExternalAppsDropdownProps={
109121
task:Task;
110122
agents:WorkspaceAgent[];
111-
externalApps:WorkspaceApp[];
123+
externalApps:AppWithAgent[];
112124
};
113125

114126
constTaskExternalAppsDropdown:FC<TaskExternalAppsDropdownProps>=({
@@ -126,16 +138,7 @@ const TaskExternalAppsDropdown: FC<TaskExternalAppsDropdownProps> = ({
126138
</Button>
127139
</DropdownMenuTrigger>
128140
<DropdownMenuContent>
129-
{externalApps.map((app)=>{
130-
constagent=agents.find((agent)=>
131-
agent.apps.some((a)=>a.id===app.id),
132-
);
133-
if(!agent){
134-
thrownewError(
135-
`Agent for app${app.id} not found in task workspace`,
136-
);
137-
}
138-
141+
{externalApps.map(({ app, agent})=>{
139142
constlink=useAppLink(app,{
140143
agent,
141144
workspace:task.workspace,
@@ -163,20 +166,18 @@ const TaskExternalAppsDropdown: FC<TaskExternalAppsDropdownProps> = ({
163166
typeTaskAppTabProps={
164167
task:Task;
165168
app:WorkspaceApp;
169+
agent:WorkspaceAgent;
166170
active:boolean;
167171
onClick:(e:React.MouseEvent<HTMLAnchorElement>)=>void;
168172
};
169173

170-
constTaskAppTab:FC<TaskAppTabProps>=({ task, app, active, onClick})=>{
171-
constagent=task.workspace.latest_build.resources
172-
.flatMap((r)=>r.agents)
173-
.filter((a)=>!!a)
174-
.find((a)=>a.apps.some((a)=>a.id===app.id));
175-
176-
if(!agent){
177-
thrownewError(`Agent for app${app.id} not found in task workspace`);
178-
}
179-
174+
constTaskAppTab:FC<TaskAppTabProps>=({
175+
task,
176+
app,
177+
agent,
178+
active,
179+
onClick,
180+
})=>{
180181
constlink=useAppLink(app,{
181182
agent,
182183
workspace:task.workspace,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp