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

Commit13449b9

Browse files
feat: embed chat ui in the task sidebar (#18216)
**Demo:**<img width="1512" alt="Screenshot 2025-06-03 at 14 36 25"src="https://github.com/user-attachments/assets/e4a61bd3-2182-4593-991d-5db9573a5b7f"/>- Extract components to be reused and easier to reasoning about - When having cloude-code-web, embed the chat in the sidebar - The sidebar will be wider when having the chat to better fit that **Does not include:**- Sidebar width drag and drop control. The width is static but would benice to have a control to customize it.
1 parent63adfa5 commit13449b9

File tree

5 files changed

+445
-391
lines changed

5 files changed

+445
-391
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
importtype{WorkspaceApp}from"api/typesGenerated";
2+
import{useAppLink}from"modules/apps/useAppLink";
3+
importtype{Task}from"modules/tasks/tasks";
4+
importtype{FC}from"react";
5+
import{cn}from"utils/cn";
6+
7+
typeTaskAppIFrameProps={
8+
task:Task;
9+
app:WorkspaceApp;
10+
active:boolean;
11+
};
12+
13+
exportconstTaskAppIFrame:FC<TaskAppIFrameProps>=({
14+
task,
15+
app,
16+
active,
17+
})=>{
18+
constagent=task.workspace.latest_build.resources
19+
.flatMap((r)=>r.agents)
20+
.filter((a)=>!!a)
21+
.find((a)=>a.apps.some((a)=>a.id===app.id));
22+
23+
if(!agent){
24+
thrownewError(`Agent for app${app.id} not found in task workspace`);
25+
}
26+
27+
constlink=useAppLink(app,{
28+
agent,
29+
workspace:task.workspace,
30+
});
31+
32+
return(
33+
<iframe
34+
src={link.href}
35+
title={link.label}
36+
loading="eager"
37+
className={cn([active ?"block" :"hidden","w-full h-full border-0"])}
38+
/>
39+
);
40+
};

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

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
importtype{WorkspaceApp}from"api/typesGenerated";
2+
import{Button}from"components/Button/Button";
3+
import{
4+
DropdownMenu,
5+
DropdownMenuContent,
6+
DropdownMenuItem,
7+
DropdownMenuTrigger,
8+
}from"components/DropdownMenu/DropdownMenu";
9+
import{ExternalImage}from"components/ExternalImage/ExternalImage";
10+
import{ChevronDownIcon,LayoutGridIcon}from"lucide-react";
11+
import{useAppLink}from"modules/apps/useAppLink";
12+
importtype{Task}from"modules/tasks/tasks";
13+
importtypeReactfrom"react";
14+
import{typeFC,useState}from"react";
15+
import{LinkasRouterLink}from"react-router-dom";
16+
import{cn}from"utils/cn";
17+
import{TaskAppIFrame}from"./TaskAppIframe";
18+
import{AI_APP_CHAT_SLUG}from"./constants";
19+
20+
typeTaskAppsProps={
21+
task:Task;
22+
};
23+
24+
exportconstTaskApps:FC<TaskAppsProps>=({ task})=>{
25+
constagents=task.workspace.latest_build.resources
26+
.flatMap((r)=>r.agents)
27+
.filter((a)=>!!a);
28+
29+
// The Chat UI app will be displayed in the sidebar, so we don't want to show
30+
// it here
31+
constapps=agents
32+
.flatMap((a)=>a?.apps)
33+
.filter((a)=>!!a&&a.slug!==AI_APP_CHAT_SLUG);
34+
35+
const[activeAppId,setActiveAppId]=useState<string>(()=>{
36+
constappId=task.workspace.latest_app_status?.app_id;
37+
if(!appId){
38+
thrownewError("No active app found in task");
39+
}
40+
returnappId;
41+
});
42+
43+
constactiveApp=apps.find((app)=>app.id===activeAppId);
44+
if(!activeApp){
45+
thrownewError(`Active app with ID${activeAppId} not found in task`);
46+
}
47+
48+
constagent=agents.find((a)=>
49+
a.apps.some((app)=>app.id===activeAppId),
50+
);
51+
if(!agent){
52+
thrownewError(`Agent for app${activeAppId} not found in task workspace`);
53+
}
54+
55+
constembeddedApps=apps.filter((app)=>!app.external);
56+
constexternalApps=apps.filter((app)=>app.external);
57+
58+
return(
59+
<mainclassName="flex-1 flex flex-col">
60+
<divclassName="border-0 border-b border-border border-solid w-full p-1 flex gap-2">
61+
{embeddedApps.map((app)=>(
62+
<TaskAppButton
63+
key={app.id}
64+
task={task}
65+
app={app}
66+
active={app.id===activeAppId}
67+
onClick={(e)=>{
68+
e.preventDefault();
69+
setActiveAppId(app.id);
70+
}}
71+
/>
72+
))}
73+
74+
{externalApps.length>0&&(
75+
<divclassName="ml-auto">
76+
<DropdownMenu>
77+
<DropdownMenuTriggerasChild>
78+
<Buttonsize="sm"variant="subtle">
79+
Open locally
80+
<ChevronDownIcon/>
81+
</Button>
82+
</DropdownMenuTrigger>
83+
<DropdownMenuContent>
84+
{externalApps.map((app)=>{
85+
constlink=useAppLink(app,{
86+
agent,
87+
workspace:task.workspace,
88+
});
89+
90+
return(
91+
<DropdownMenuItemkey={app.id}asChild>
92+
<RouterLinkto={link.href}>
93+
{app.icon ?(
94+
<ExternalImagesrc={app.icon}/>
95+
) :(
96+
<LayoutGridIcon/>
97+
)}
98+
{link.label}
99+
</RouterLink>
100+
</DropdownMenuItem>
101+
);
102+
})}
103+
</DropdownMenuContent>
104+
</DropdownMenu>
105+
</div>
106+
)}
107+
</div>
108+
109+
<divclassName="flex-1">
110+
{embeddedApps.map((app)=>{
111+
return(
112+
<TaskAppIFrame
113+
key={app.id}
114+
active={activeAppId===app.id}
115+
app={app}
116+
task={task}
117+
/>
118+
);
119+
})}
120+
</div>
121+
</main>
122+
);
123+
};
124+
125+
typeTaskAppButtonProps={
126+
task:Task;
127+
app:WorkspaceApp;
128+
active:boolean;
129+
onClick:(e:React.MouseEvent<HTMLAnchorElement>)=>void;
130+
};
131+
132+
constTaskAppButton:FC<TaskAppButtonProps>=({
133+
task,
134+
app,
135+
active,
136+
onClick,
137+
})=>{
138+
constagent=task.workspace.latest_build.resources
139+
.flatMap((r)=>r.agents)
140+
.filter((a)=>!!a)
141+
.find((a)=>a.apps.some((a)=>a.id===app.id));
142+
143+
if(!agent){
144+
thrownewError(`Agent for app${app.id} not found in task workspace`);
145+
}
146+
147+
constlink=useAppLink(app,{
148+
agent,
149+
workspace:task.workspace,
150+
});
151+
152+
return(
153+
<Button
154+
size="sm"
155+
variant="subtle"
156+
key={app.id}
157+
asChild
158+
className={cn([
159+
{"text-content-primary":active},
160+
{"opacity-75 hover:opacity-100":!active},
161+
])}
162+
>
163+
<RouterLinkto={link.href}onClick={onClick}>
164+
{app.icon ?<ExternalImagesrc={app.icon}/> :<LayoutGridIcon/>}
165+
{link.label}
166+
</RouterLink>
167+
</Button>
168+
);
169+
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp