fix(site): filter agents workspace dropdown to owner and show owner/name format (#22409)

This commit is contained in:
Danielle Maywood
2026-02-28 11:01:23 +00:00
committed by GitHub
parent 31ad3cdd0c
commit bde772cfa3
2 changed files with 52 additions and 6 deletions
@@ -1,3 +1,4 @@
import { MockWorkspace } from "testHelpers/entities";
import type { Meta, StoryObj } from "@storybook/react-vite";
import { API } from "api/api";
import { useRef } from "react";
@@ -76,6 +77,48 @@ type Story = StoryObj<typeof AgentsEmptyStateWithPortal>;
export const Default: Story = {};
export const WithWorkspaces: Story = {
beforeEach: () => {
localStorage.clear();
spyOn(API, "getWorkspaces").mockResolvedValue({
workspaces: [
{
...MockWorkspace,
id: "ws-1",
name: "my-project",
owner_name: "johndoe",
owner_id: "user-1",
},
{
...MockWorkspace,
id: "ws-2",
name: "my-project",
owner_name: "janedoe",
owner_id: "user-2",
},
{
...MockWorkspace,
id: "ws-3",
name: "backend-api",
owner_name: "johndoe",
owner_id: "user-1",
},
],
count: 3,
});
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
await waitFor(() => {
const trigger = canvas.getByText("Workspace").closest("button")!;
expect(trigger).toBeEnabled();
});
await userEvent.click(canvas.getByText("Workspace").closest("button")!);
// Wait for the portalled dropdown to appear so Chromatic captures it.
await within(canvasElement.ownerDocument.body).findByRole("listbox");
},
};
export const SavesBehaviorPromptAndRestores: Story = {
play: async ({ canvasElement }) => {
const host = canvasElement.ownerDocument.querySelector(
+9 -6
View File
@@ -597,7 +597,7 @@ export const AgentsEmptyState: FC<AgentsEmptyStateProps> = ({
useState(initialSystemPrompt);
const [isConfigureAgentsDialogOpen, setConfigureAgentsDialogOpen] =
useState(false);
const workspacesQuery = useQuery(workspaces({ limit: 50 }));
const workspacesQuery = useQuery(workspaces({ q: "owner:me", limit: 50 }));
const [selectedWorkspaceId, setSelectedWorkspaceId] = useState<string | null>(
() => {
if (typeof window === "undefined") return null;
@@ -711,9 +711,12 @@ export const AgentsEmptyState: FC<AgentsEmptyStateProps> = ({
[onCreateChat],
);
const selectedWorkspaceName = selectedWorkspaceId
? workspaceOptions.find((ws) => ws.id === selectedWorkspaceId)?.name
: null;
const selectedWorkspace = selectedWorkspaceId
? workspaceOptions.find((ws) => ws.id === selectedWorkspaceId)
: undefined;
const selectedWorkspaceLabel = selectedWorkspace
? `${selectedWorkspace.owner_name}/${selectedWorkspace.name}`
: undefined;
return (
<div className="flex min-h-0 flex-1 items-start justify-center overflow-auto p-4 pt-12 md:h-full md:items-center md:pt-4">
@@ -760,7 +763,7 @@ export const AgentsEmptyState: FC<AgentsEmptyStateProps> = ({
<SelectTrigger className="h-8 w-auto gap-1.5 border-none bg-transparent px-1 text-xs shadow-none transition-colors hover:bg-transparent hover:text-content-primary [&>svg]:transition-colors [&>svg]:hover:text-content-primary focus:ring-0 focus-visible:ring-0">
<MonitorIcon className="h-3.5 w-3.5 shrink-0 text-content-secondary group-hover:text-content-primary" />
<SelectValue>
{selectedWorkspaceName ?? "Workspace"}
{selectedWorkspaceLabel ?? "Workspace"}
</SelectValue>
</SelectTrigger>
<SelectContent
@@ -773,7 +776,7 @@ export const AgentsEmptyState: FC<AgentsEmptyStateProps> = ({
</SelectItem>
{workspaceOptions.map((workspace) => (
<SelectItem key={workspace.id} value={workspace.id}>
{workspace.name}
{workspace.owner_name}/{workspace.name}
</SelectItem>
))}
{workspaceOptions.length === 0 &&