Skip to content

Commit a23db94

Browse files
authored
fix(studio): streamline agent creation navigation (#948)
1 parent 8e481db commit a23db94

5 files changed

Lines changed: 32 additions & 43 deletions

File tree

frontend/src/create/CustomCreate.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2820,8 +2820,8 @@ type DebugPhase = "idle" | "starting" | "ready" | "sending" | "error";
28202820

28212821
type WorkspaceMode =
28222822
| "build"
2823-
| "optimize"
28242823
| "validate"
2824+
| "optimize"
28252825
| "environment"
28262826
| "publish";
28272827
interface DebugMessage {
@@ -3552,16 +3552,16 @@ const WORKSPACE_MODES: Array<{
35523552
label: string;
35533553
}> = [
35543554
{ id: "build", label: "架构" },
3555-
{ id: "optimize", label: "优化" },
35563555
{ id: "validate", label: "调试" },
3556+
{ id: "optimize", label: "优化" },
35573557
{ id: "environment", label: "环境" },
35583558
{ id: "publish", label: "发布" },
35593559
];
35603560

35613561
const WORKSPACE_TITLES: Record<WorkspaceMode, string> = {
35623562
build: "个性化您的智能体架构",
3563-
optimize: "为您的智能体选择优化项",
35643563
validate: "调试您的智能体",
3564+
optimize: "为您的智能体选择优化项",
35653565
environment: "配置云上环境",
35663566
publish: "准备好部署您的智能体",
35673567
};
@@ -4704,14 +4704,14 @@ export function CustomCreate({
47044704
await materializePublishRelease();
47054705
return;
47064706
}
4707-
if (nextMode === "optimize") {
4708-
await openOptimization();
4709-
return;
4710-
}
47114707
if (nextMode === "validate") {
47124708
openValidation();
47134709
return;
47144710
}
4711+
if (nextMode === "optimize") {
4712+
await openOptimization();
4713+
return;
4714+
}
47154715
if (nextMode === "environment") {
47164716
void openEnvironment();
47174717
return;
@@ -5665,16 +5665,6 @@ export function CustomCreate({
56655665
</div>
56665666
)}
56675667

5668-
{workspaceMode === "optimize" && (
5669-
<HarnessOptimizationWorkspace
5670-
profile={harnessOptimizationProfile}
5671-
optimizations={harnessOptimizations}
5672-
unavailableMessage={harnessProviderNotice}
5673-
onProfileChange={updateHarnessOptimizationProfile}
5674-
onOptimizationChange={updateHarnessOptimization}
5675-
/>
5676-
)}
5677-
56785668
{workspaceMode === "validate" && (
56795669
<div className="cw-validation-workspace">
56805670
<div className="cw-validation-content">
@@ -5703,6 +5693,16 @@ export function CustomCreate({
57035693
</div>
57045694
)}
57055695

5696+
{workspaceMode === "optimize" && (
5697+
<HarnessOptimizationWorkspace
5698+
profile={harnessOptimizationProfile}
5699+
optimizations={harnessOptimizations}
5700+
unavailableMessage={harnessProviderNotice}
5701+
onProfileChange={updateHarnessOptimizationProfile}
5702+
onOptimizationChange={updateHarnessOptimization}
5703+
/>
5704+
)}
5705+
57065706
{workspaceMode === "environment" && (
57075707
<div className="cw-environment-workspace">
57085708
<CloudEnvironmentConfigurator

frontend/src/ui/Sidebar.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ export function Sidebar({
312312
userInfo,
313313
onLogout,
314314
}: SidebarProps) {
315-
// The legacy full-page creator remains outside the main navigation.
315+
// Agent creation remains outside the main navigation.
316+
void onQuickCreate;
316317
void onAddAgent;
317318
// Per-module feature gates; a missing flag defaults to shown.
318319
const show = (k: keyof NonNullable<typeof features>) => features?.[k] !== false;
@@ -423,17 +424,6 @@ export function Sidebar({
423424
<AgentFaceIcon />
424425
<span className="sidebar-nav-label">智能体</span>
425426
</button>
426-
{access.capabilities.createAgents && show("addAgent") ? (
427-
<button
428-
className="new-chat new-chat--add-agent"
429-
onClick={onQuickCreate}
430-
aria-label="添加智能体"
431-
title="添加智能体"
432-
>
433-
<Plus className="icon" />
434-
<span className="sidebar-nav-label">添加智能体</span>
435-
</button>
436-
) : null}
437427
<button
438428
className={`new-chat new-chat--library${
439429
activePage === "library" ? " is-active" : ""

frontend/tests/harnessSidecarOptions.test.mjs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,20 +202,24 @@ test("derives Model Proxy dependencies from the selected optimization catalog",
202202
]);
203203
});
204204

205-
test("places the Harness optimization page second, before debugging", () => {
205+
test("places the Harness optimization page immediately before environment setup", () => {
206206
assert.match(
207207
customCreateSource,
208-
/type WorkspaceMode =[\s\S]*?\| "optimize"[\s\S]*?\| "validate"[\s\S]*?\| "publish";/,
208+
/type WorkspaceMode =[\s\S]*?\| "validate"[\s\S]*?\| "optimize"[\s\S]*?\| "environment"[\s\S]*?\| "publish";/,
209209
);
210210
assert.match(
211211
customCreateSource,
212-
/\{ id: "build", label: "" \},\s*\{ id: "optimize", label: "" \},\s*\{ id: "validate", label: "" \},\s*\{ id: "environment", label: "" \},\s*\{ id: "publish", label: "" \}/,
212+
/\{ id: "build", label: "" \},\s*\{ id: "validate", label: "" \},\s*\{ id: "optimize", label: "" \},\s*\{ id: "environment", label: "" \},\s*\{ id: "publish", label: "" \}/,
213213
);
214214
assert.match(customCreateSource, /optimize:\s*""/);
215215
assert.doesNotMatch(customCreateSource, //);
216+
assert.ok(
217+
customCreateSource.indexOf('{workspaceMode === "validate"') <
218+
customCreateSource.indexOf('{workspaceMode === "optimize"'),
219+
);
216220
assert.ok(
217221
customCreateSource.indexOf('{workspaceMode === "optimize"') <
218-
customCreateSource.indexOf('{workspaceMode === "validate"'),
222+
customCreateSource.indexOf('{workspaceMode === "environment"'),
219223
);
220224
assert.match(
221225
customCreateSource,

frontend/tests/myAgents.test.mjs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,9 @@ test("shows only the Agent navigation in the sidebar", () => {
4545
assert.match(appSource, /myAgents && !showManageAgents \? \([\s\S]*?<MyAgents/);
4646
});
4747

48-
test("opens Agent creation directly without visiting the Runtime-backed library", () => {
49-
assert.match(
50-
sidebarSource,
51-
/access\.capabilities\.createAgents && show\("addAgent"\)[\s\S]*?onClick=\{onQuickCreate\}[\s\S]*?aria-label=""/,
52-
);
53-
assert.match(
54-
appSource,
55-
/onQuickCreate=\{\(\) => requestIntelligentNavigation\(\(\) => \{[\s\S]*?setCreateView\(null\)[\s\S]*?setAddMenu\(true\)/,
56-
);
48+
test("keeps Agent creation out of the sidebar navigation", () => {
49+
assert.doesNotMatch(sidebarSource, /new-chat--add-agent/);
50+
assert.doesNotMatch(sidebarSource, /aria-label=""/);
5751
});
5852

5953
test("shows the requested title, search, and agent type pills", () => {

frontend/tests/studioAccess.test.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ test("Studio entry telemetry uses anonymous UI config metadata", () => {
3535
});
3636

3737
test("Agent workspace creation and update actions obey Studio access", () => {
38-
assert.match(sidebarSource, /access\.capabilities\.createAgents && show\("addAgent"\)/);
38+
assert.doesNotMatch(sidebarSource, /access\.capabilities\.createAgents && show\("addAgent"\)/);
3939
assert.doesNotMatch(sidebarSource, /access\.capabilities\.manageAgents && show\("manageAgents"\)/);
4040
assert.doesNotMatch(sidebarSource, /onManageAgents/);
41+
assert.match(appSource, /<MyAgents[\s\S]*?canCreate=\{canCreateAgents\}/);
4142
assert.match(appSource, /const visibleCreateView = canCreateAgents \? createView : null/);
4243
assert.match(appSource, /const showManageAgents = manageAgents/);
4344
assert.match(appSource, /if \(!access\.capabilities\.manageAgents\) setManageAgents\(false\)/);

0 commit comments

Comments
 (0)