Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion apps/aevatar-console-web/src/pages/studio/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3489,6 +3489,17 @@ describe("StudioPage", () => {
});
});

it("returns to canonical Team detail when Studio has Team context", async () => {
renderStudioPage("/studio?scopeId=scope-1&teamId=t-alpha&memberId=workspace-demo&focus=workflow%3Aworkflow-1&tab=studio");

fireEvent.click(await screen.findByRole("button", { name: "返回团队" }));

expect(window.location.pathname).toBe("/teams/scope-1/t-alpha");
const searchParams = new URLSearchParams(window.location.search);
expect(searchParams.get("memberId")).toBe("workspace-demo");
expect(searchParams.get("tab")).toBe("advanced");
});

it("moves focus from a Script draft to the new Workflow member after create", async () => {
(studioApi.getAppContext as jest.Mock).mockResolvedValueOnce({
...defaultStudioAppContext,
Expand Down Expand Up @@ -5739,7 +5750,7 @@ describe("StudioPage", () => {
});

it("opens the Studio invoke surface from the bind surface endpoint action", async () => {
renderStudioPage("/studio?scopeId=scope-1&focus=workflow%3Aworkflow-1&tab=studio");
renderStudioPage("/studio?scopeId=scope-1&teamId=t-alpha&memberId=workspace-demo&focus=workflow%3Aworkflow-1&tab=studio");

fireEvent.click(await screen.findByRole("button", { name: "Bind" }));
fireEvent.click(await screen.findByRole("button", { name: "Continue to Invoke" }));
Expand All @@ -5749,6 +5760,11 @@ describe("StudioPage", () => {
expect(screen.getByText("service:default")).toBeTruthy();
expect(screen.getByText("endpoint:support-chat")).toBeTruthy();
});

const searchParams = new URLSearchParams(window.location.search);
expect(searchParams.get("teamId")).toBe("t-alpha");
expect(searchParams.get("member")).toBe("member:workspace-demo");
expect(searchParams.get("step")).toBe("invoke");
});

it("pins Observe to the selected member service and corrects stale run selection", async () => {
Expand Down
31 changes: 30 additions & 1 deletion apps/aevatar-console-web/src/pages/studio/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3943,6 +3943,7 @@ const StudioPage: React.FC = () => {
history.replace(
buildStudioRoute({
scopeId: resolvedStudioScopeId || undefined,
teamId: routeState.teamId || undefined,
memberKey: boundMemberKey,
step: 'bind',
}),
Expand All @@ -3958,6 +3959,7 @@ const StudioPage: React.FC = () => {
resolvedStudioScopeId,
routeState.memberId,
routeState.memberKey,
routeState.teamId,
selectedScriptId,
selectedWorkflowMemberKey,
scopeServicesQuery,
Expand Down Expand Up @@ -4684,6 +4686,7 @@ const StudioPage: React.FC = () => {
history.replace(
buildStudioRoute({
scopeId: resolvedStudioScopeId || undefined,
teamId: routeState.teamId || undefined,
focus: `workflow:${fallbackWorkflowId}`,
step: 'build',
tab: 'studio',
Expand All @@ -4694,6 +4697,7 @@ const StudioPage: React.FC = () => {
history.replace(
buildStudioRoute({
scopeId: resolvedStudioScopeId || undefined,
teamId: routeState.teamId || undefined,
step: 'build',
tab: 'studio',
}),
Expand Down Expand Up @@ -5401,6 +5405,7 @@ const StudioPage: React.FC = () => {
history.replace(
buildStudioRoute({
scopeId: resolvedStudioScopeId || undefined,
teamId: routeState.teamId || undefined,
memberKey:
trimOptional(routeState.memberKey) ||
(resolvedMemberId
Expand All @@ -5422,6 +5427,7 @@ const StudioPage: React.FC = () => {
resolvedStudioScopeId,
routeState.memberId,
routeState.memberKey,
routeState.teamId,
studioScopeMembers,
],
);
Expand Down Expand Up @@ -6744,6 +6750,7 @@ const StudioPage: React.FC = () => {
history.push(
buildStudioRoute({
scopeId: resolvedStudioScopeId || undefined,
teamId: routeState.teamId || undefined,
memberKey: normalizedMemberKey,
step: currentLifecycleStep,
}),
Expand All @@ -6754,6 +6761,7 @@ const StudioPage: React.FC = () => {
history.push(
buildStudioRoute({
scopeId: resolvedStudioScopeId || undefined,
teamId: routeState.teamId || undefined,
memberKey: normalizedMemberKey,
tab: 'studio',
}),
Expand Down Expand Up @@ -6783,6 +6791,7 @@ const StudioPage: React.FC = () => {
history.push(
buildStudioRoute({
scopeId: resolvedStudioScopeId || undefined,
teamId: routeState.teamId || undefined,
memberKey: normalizedMemberKey,
step: currentLifecycleStep,
}),
Expand All @@ -6793,6 +6802,7 @@ const StudioPage: React.FC = () => {
history.push(
buildStudioRoute({
scopeId: resolvedStudioScopeId || undefined,
teamId: routeState.teamId || undefined,
memberKey: normalizedMemberKey,
tab: 'scripts',
}),
Expand Down Expand Up @@ -6851,6 +6861,7 @@ const StudioPage: React.FC = () => {
history.push(
buildStudioRoute({
scopeId: resolvedStudioScopeId || undefined,
teamId: routeState.teamId || undefined,
memberKey: workflowMemberKey,
tab: 'studio',
}),
Expand All @@ -6876,6 +6887,7 @@ const StudioPage: React.FC = () => {
history.push(
buildStudioRoute({
scopeId: resolvedStudioScopeId || undefined,
teamId: routeState.teamId || undefined,
memberKey: `script:${scriptId}`,
tab: 'scripts',
}),
Expand Down Expand Up @@ -6937,6 +6949,7 @@ const StudioPage: React.FC = () => {
history.push(
buildStudioRoute({
scopeId: resolvedStudioScopeId || undefined,
teamId: routeState.teamId || undefined,
memberKey:
selectedMemberId ? `member:${selectedMemberId}` : normalizedMemberKey,
step: currentLifecycleStep,
Expand All @@ -6949,6 +6962,7 @@ const StudioPage: React.FC = () => {
history.push(
buildStudioRoute({
scopeId: resolvedStudioScopeId || undefined,
teamId: routeState.teamId || undefined,
memberKey: selectedMemberOwnerKey,
tab: 'studio',
}),
Expand All @@ -6961,6 +6975,7 @@ const StudioPage: React.FC = () => {
history.push(
buildStudioRoute({
scopeId: resolvedStudioScopeId || undefined,
teamId: routeState.teamId || undefined,
memberKey: selectedMemberOwnerKey,
tab: 'scripts',
}),
Expand All @@ -6972,6 +6987,7 @@ const StudioPage: React.FC = () => {
history.push(
buildStudioRoute({
scopeId: resolvedStudioScopeId || undefined,
teamId: routeState.teamId || undefined,
memberKey: selectedMemberOwnerKey,
step: 'bind',
}),
Expand Down Expand Up @@ -7000,6 +7016,7 @@ const StudioPage: React.FC = () => {
publishedScopeMembers,
publishedScopeServices,
resolvedStudioScopeId,
routeState.teamId,
studioSurface,
visibleWorkflowSummaries,
workbenchMemberKey,
Expand Down Expand Up @@ -7631,7 +7648,18 @@ const StudioPage: React.FC = () => {
.map((value) => trimOptional(value))
.filter(Boolean);
const studioReturnHref = resolvedStudioScopeId
? buildTeamDetailHref({
? routeState.teamId
? buildTeamDetailHref({
scopeId: resolvedStudioScopeId,
teamId: routeState.teamId,
tab: 'advanced',
memberId:
trimOptional(routeState.memberId) ||
readMemberIdFromMemberKey(routeState.memberKey) ||
undefined,
serviceId: trimOptional(workbenchPublishedService?.serviceId) || undefined,
})
: buildTeamDetailHref({
scopeId: resolvedStudioScopeId,
tab: 'advanced',
serviceId:
Expand Down Expand Up @@ -7915,6 +7943,7 @@ const StudioPage: React.FC = () => {
history.push(
buildStudioRoute({
scopeId: resolvedStudioScopeId || undefined,
teamId: routeState.teamId || undefined,
memberKey: selectedScriptId ? `script:${selectedScriptId}` : undefined,
step: 'bind',
tab: 'bindings',
Expand Down
22 changes: 14 additions & 8 deletions apps/aevatar-console-web/src/pages/teams/detail.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,9 @@ describe("TeamDetailPage", () => {
level: 1,
name: "Alpha Support Team",
});
await waitFor(() => {
expect(studioApi.listTeamMembers).toHaveBeenCalledWith("scope-1", "t-alpha");
});
await waitFor(() => {
expect(scopesApi.getWorkflowDetail).toHaveBeenCalledWith("scope-1", "workflow-1");
});
Expand All @@ -1558,9 +1561,9 @@ describe("TeamDetailPage", () => {
const params = pushedUrl.searchParams;
expect(params.get("scopeId")).toBe("scope-1");
expect(params.get("teamId")).toBe("t-alpha");
expect(params.get("member")).toBe("workflow:workflow-1");
expect(params.get("member")).toBe("member:member-team-alpha");
expect(params.get("memberId")).toBeNull();
expect(params.get("focus")).toBeNull();
expect(params.get("focus")).toBe("workflow:workflow-1");
expect(params.get("tab")).toBe("studio");
pushSpy.mockRestore();
});
Expand All @@ -1571,17 +1574,19 @@ describe("TeamDetailPage", () => {
await screen.findByRole("button", { name: "服务映射" });
fireEvent.click(screen.getByRole("button", { name: "Assets" }));
await screen.findByText("当前 Team 资产");
await waitFor(() => {
expect(studioApi.listTeamMembers).toHaveBeenCalledWith("scope-1", "t-alpha");
});

fireEvent.click(screen.getByRole("button", { name: "打开 workflow Support Escalation Triage" }));

await waitFor(() => {
expect(window.location.pathname).toBe("/studio");
});
expect(window.location.search).toContain("scopeId=scope-1");
expect(window.location.search).toContain("member=workflow%3Aworkflow-1");
expect(window.location.search).not.toContain(
"focus=workflow%3Aworkflow-1",
);
expect(window.location.search).toContain("teamId=t-alpha");
expect(window.location.search).toContain("member=member%3Amember-team-alpha");
expect(window.location.search).toContain("focus=workflow%3Aworkflow-1");

cleanup();
window.history.replaceState({}, "", "/teams/scope-1/t-alpha?tab=assets");
Expand All @@ -1594,8 +1599,9 @@ describe("TeamDetailPage", () => {
expect(window.location.pathname).toBe("/studio");
});
expect(window.location.search).toContain("scopeId=scope-1");
expect(window.location.search).toContain("member=script%3Ascript-1");
expect(window.location.search).not.toContain("focus=script%3Ascript-1");
expect(window.location.search).toContain("teamId=t-alpha");
expect(window.location.search).toContain("member=member%3Amember-team-alpha");
expect(window.location.search).toContain("focus=script%3Ascript-1");
expect(window.location.search).toContain("tab=scripts");
});

Expand Down
64 changes: 41 additions & 23 deletions apps/aevatar-console-web/src/pages/teams/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
buildStudioScriptsWorkspaceRoute,
buildStudioWorkflowEditorRoute,
buildStudioWorkflowWorkspaceRoute,
resolveStudioMemberRouteKey,
} from "@/shared/studio/navigation";
import {
formatStudioMemberLifecycleStage,
Expand Down Expand Up @@ -1476,6 +1477,7 @@ const TeamDetailPage: React.FC = () => {
lens.currentService?.serviceId ||
lens.currentRun?.serviceId ||
undefined;
const firstTeamRosterMemberId = trimText(teamMembersQuery.data?.members?.[0]?.memberId);
const currentMemberId =
trimText(preferredMemberSummary?.memberId) ||
trimText(preferredMemberId);
Expand Down Expand Up @@ -1522,25 +1524,33 @@ const TeamDetailPage: React.FC = () => {
}),
[currentPlatformService?.appId, currentPlatformService?.namespace, currentPlatformService?.tenantId, runtimeServiceId, scopeId],
);
const selectedStudioBackendMemberId =
firstTeamRosterMemberId || (hasTeamIdentity ? "" : currentMemberId);
const selectedStudioLegacyMemberId =
hasTeamIdentity
? ""
: trimText(runtimeServiceId) ||
trimText(serviceRevisionsQuery.data?.serviceId) ||
trimText(preferredServiceId) ||
trimText(servicesQuery.data?.[0]?.serviceId) ||
trimText(activeWorkflowSummary?.serviceKey).split(":").pop()?.trim() ||
"";
const selectedStudioMemberId =
currentMemberId ||
trimText(runtimeServiceId) ||
trimText(serviceRevisionsQuery.data?.serviceId) ||
trimText(preferredServiceId) ||
trimText(servicesQuery.data?.[0]?.serviceId) ||
trimText(activeWorkflowSummary?.serviceKey).split(":").pop()?.trim() ||
"";
selectedStudioBackendMemberId || selectedStudioLegacyMemberId;
const selectedStudioWorkflowMemberKey = buildStudioWorkflowMemberKey({
workflowId: activeWorkflowSummary?.workflowId,
workflowName:
trimText(activeWorkflowSummary?.displayName) ||
trimText(activeWorkflowSummary?.workflowName),
});
const selectedStudioMemberKey =
trimText(activeWorkflowSummary?.workflowId).length > 0
? buildStudioWorkflowMemberKey({
workflowId: activeWorkflowSummary?.workflowId,
workflowName:
trimText(activeWorkflowSummary?.displayName) ||
trimText(activeWorkflowSummary?.workflowName),
})
: selectedStudioMemberId
? `member:${selectedStudioMemberId}`
: undefined;
resolveStudioMemberRouteKey({
memberId: selectedStudioBackendMemberId,
memberKey: selectedStudioWorkflowMemberKey,
}) ||
resolveStudioMemberRouteKey({
memberId: selectedStudioLegacyMemberId,
});

const teamBuilderRoute =
trimText(activeWorkflowSummary?.workflowId).length > 0
Expand Down Expand Up @@ -3696,26 +3706,34 @@ const TeamDetailPage: React.FC = () => {
history.push(
buildStudioWorkflowEditorRoute({
scopeId,
memberKey:
trimText(workflowId).length > 0 ? `workflow:${trimText(workflowId)}` : undefined,
teamId: selectedTeamId || undefined,
memberKey: resolveStudioMemberRouteKey({
memberId: selectedStudioBackendMemberId,
memberKey: selectedStudioMemberKey,
workflowId,
}),
workflowId,
}),
);
},
[scopeId],
[scopeId, selectedStudioBackendMemberId, selectedStudioMemberKey, selectedTeamId],
);
const handleOpenScriptAsset = React.useCallback(
(scriptId: string) => {
history.push(
buildStudioScriptsWorkspaceRoute({
scopeId,
memberKey:
trimText(scriptId).length > 0 ? `script:${trimText(scriptId)}` : undefined,
teamId: selectedTeamId || undefined,
memberKey: resolveStudioMemberRouteKey({
memberId: selectedStudioBackendMemberId,
memberKey: selectedStudioMemberKey,
scriptId,
}),
scriptId,
}),
);
},
[scopeId],
[scopeId, selectedStudioBackendMemberId, selectedStudioMemberKey, selectedTeamId],
);

const renderOverviewTab = () => {
Expand Down
3 changes: 2 additions & 1 deletion apps/aevatar-console-web/src/pages/teams/home.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ describe("TeamsHomePage", () => {

const params = new URLSearchParams(window.location.search);
expect(params.get("scopeId")).toBe("scope-a");
expect(params.get("teamId")).toBeNull();
expect(params.get("teamId")).toBe("t-support");
expect(params.get("member")).toBe("member:member-alpha");
expect(params.get("tab")).toBe("studio");
});

Expand Down
Loading
Loading